Pagination

As adoption of Spark continues to skyrocket, so does the amount of content being shared by team members. We've addressed this in the Spark APIs by introducing support for pagination.

It would be impractical to return all messages in a busy room, for example. With pagination, the Spark API returns a specific number of items at a time; allowing your app to request another page as needed.

Controlling Page Size

When requesting a list of resources the max query parameter may be used to control the number of items returned per page. For example, requesting GET /people?displayName=Harold&max=2 tells Spark to return only 2 items per page.

Navigating Pages

Spark APIs implement the RFC5988 (Web Linking) standard for pagination. When requesting a list of resources the response may contain a Link header containing the URLs to the first, next, and previous page.

For example, requesting GET /people?displayName=Harold may return a link header like this one:

Link: <https://api.ciscospark.com/v1/people?displayName=Harold&max=10&before&after=Y2lzY29zcGFyazovL3VzL1BFT1BMRS83MTZlOWQxYy1jYTQ0LTRmZWQtOGZjYS05ZGY0YjRmNDE3ZjU> rel="next"

Notice the rel="next" at the end of the line. This tells your app that another page is available and provides the URL to fetch it.

The list of possible relationship types are:

next Link to the next page
first Link back to the first page
prev Link to the previous page

Please note that only the rel="next" link header is guaranteed at this time.

We may include other link types, that are defined in the RFC5988 (Web Linking) standard, in the future.