It is very common in API design to use pagination to break up the results of a query into smaller, more manageable responses. Both the ManageBac and OpenApply APIs use pagination to handle large amounts of data and ensure availability, especially for endpoints such as "Get all students," "Get all parents," or other endpoints known as list endpoints.
If you are experiencing issues with not being able to retrieve all the expected records, and you are using an endpoint that returns a meta property, it is highly likely the issue is due to pagination not being correctly implemented.
When using list endpoints, every response has a meta property showing exactly how many records are returned per page, and how many pages there are in total; this can be used to determine how subsequent requests that need to be made to complete the loop.
The following examples show the responses when no pagination is used. As can be seen, there are more pages which contain more records that need to be pulled.
GET https://mydomain.openapply.com/api/v3/students
GET https://api.managebac.com/v2/students
To view more than the entries on the first page you will need to use pagination. This essentially means that you need to pass a parameter to change the page number by appending the query with ? and specifying the parameter page=
For example:
GET https://mydomain.openapply.com/api/v3/students?page=2
GET https://api.managebac.com/v2/students?page=2
If you are using more parameters, you may need to add & between them. Sometimes you can return more results than the default number returned using the parameter per_page (or count). However the number of results to be returned is usually limited by the API provider, and can be subject to change. For the current limit, check the reference documentation available.
GET https://mydomain.openapply.com/api/v3/students?count=100&page=2
GET https://api.managebac.com/v2/students?page=2&per_page=200
It is best practice to keep queries to the minimum amount of information needed using parameters to control the results. Both ManageBac and OpenApply offer various parameters that can narrow down the record set significantly, for example: status, modified_since - check which are available to use for your query in the reference documentation.
GET https://mydomain.openapply.com/api/v3/students?count=100&status=pending&page=2
GET https://api.managebac.com/v2/students?page=2&per_page=200&modified_since=2022-08-10
If you are using Python, you the following example code, which utilizes the requests library:
params = {'page': 1}
requests.get(url, headers=headers, params=params)
Which will add the page
query parameter to the end of your call, via the `params` query parameter.
A more complete example follows:
page = 1
while page:
response = requests.get(url, headers=headers, params={'page': page})
content = response.json()
meta = content.get('meta')
teachers = content.get('teachers', [])
print(teachers)
page = meta.get('next_page')
In other words, loop through, passing the next page for each iteration, until there are no more pages left (page == None
which is falsy).