How to get paginated query results with the Wowza Streaming Cloud REST API

Learn how to get paginated results from REST API queries made in the Wowza Streaming Cloud™ service.

Contents


Pagination parameters
Example requests
Related requests

Pagination parameters


To execute a request that returns paginated results, use these parameters.
 
Parameter Data Type Description
page integer Specify a positive integer to indicate which page of the results should be displayed. Where multiple pages of records are returned, next and previous links allow you to navigate the results. Omit the page parameter or specify an integer that's less than or equal to 0 to view all (unpaginated) results.
per_page integer Indicates how many records should be included on each page of results. A valid value is any positive integer. The default is 10.

Oldest records are displayed first, newest records come last. Results display the following additional parameters:
 
Parameter Data Type Description
page integer The page being displayed.
page_first_index integer The 0-based index of the first record on the page returned.
page_last_index integer The 0-based index of the last record on the page returned.
per_page integer The number of records included on each page of results.
total_pages integer The total number of pages generated by the query.
total_records integer The total number of records in the database that match the query.

Example requests


You can append pagination parameters to any GET request made to the
 
  • /live_streams,
     
  • /players,
     
  • /recordings,
     
  • /schedules,
     
  • /stream_sources,
     
  • /stream_targets, and
     
  • /transcoders
resources.
 
Note: In all code examples, for [key], substitute your API key or your access key as appropriate. For more information, see Locating and using API and access keys.

Live streams example

The following request generates a paginated list of live streams that shows 25 streams per page. The first page of results will display the 25 oldest streams.
 
curl -X GET --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" "https://api.cloud.wowza.com/api/v1/live_streams/?page=1&per_page=25"
The response should look something like this:
 
{
  "live_streams": [1,2,3,...25]
   },
{
  "pagination": {
    "total_records": 541,
    "page": 1,
    "per_page": 25,
    "total_pages": 22,
    "page_first_index": 0,
    "page_last_index": 24
  }
}
| next |
Click next to go to page 2 of the results (streams 26 through 50). Then, click next or previous to continue navigating the 22 pages.

Recordings example

The following request generates a paginated list of recordings that shows 5 recordings per page. Because there happen to be 25 total records, the first page of results will display the 5 newest recordings.
 
curl -X GET --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" "https://api.cloud.wowza.com/api/v1/recordings/?page=5&per_page=5"
The response should look something like this:
 
{
  "recordings": [1,2,3,4,5]
   },
{
  "pagination": {
    "total_records": 25,
    "page": 5,
    "per_page": 5,
    "total_pages": 5,
    "page_first_index": 20,
    "page_last_index": 24
  }
}
| previous |

Stream targets example

The following request generates a paginated list of stream targets that shows 10 stream targets per page. The first page of results will display the oldest stream targets.
 
curl -X GET --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" "https://api.cloud.wowza.com/api/v1/stream_targets/?page=1&per_page=10"
The response should look something like this:
 
{
  "stream_targets": [1...10]
   },
{
  "pagination": {
    "total_records": 41,
    "page": 1,
    "per_page": 10,
    "total_pages": 5,
    "page_first_index": 10,
    "page_last_index": 1
  }
}
| next |

Related requests


Use the methods returned in the links array of the results to execute related requests.
Originally Published: 12-19-2016.
 

If you're having problems or want to discuss this article, post in our forum.