...
Pagination is most useful when implemented as part of a data discovery tool. It allows a way of quickly returning small chunks of data so that searches can be refined quickly and efficiently.
Example query body with pagination:
Code Block |
---|
{ "page_number": 1, "page_size": 5020, "query": { "dataset": [ "http://linked.data.gov.au/dataset/ausplots" ], "feature_type": [ "http://linked.data.gov.au/def/tern-cv/b311c0d3-4a1a-4932-a39c-f5cdc1afa611" ], "observed_property": [ "http://linked.data.gov.au/def/tern-cv/0bbd7fcd-0782-4efc-96e6-1f0f7669c655" ] } } |
Adding pagination to your request is as easy as include the “page_number” and “page_size” parameters to the request bodyThe above example has a page_number
of 1 and a page_size
of 20, which means that one page of results will be returned containing twenty elements.
Response headers are returned with information about the pagination:
Code Block |
---|
Pagination-Page: 1 Pagination-Size: 50 Pagination-Limit: 200 # Max number of page available. Notice that it could be smaller than the real number of pages due to the 10,000 limitation. Pagination-Count: 11827 # Total amount of elements |
Request cURL request example:
Code Block |
---|
curl -X POST "https://ecoplots-test.tern.org.au/api/v1.0/observationsfoi/attributes?dformat=ndjson" -H "accept: */*" -H "Authorization: apikey-v1 ZjF6eUpHaE1uRDFwNmRIUi5UcHVkQVUMVHFoYn5QcU1MeF4KVydnISwtclR3dHpZaSg7dHVFeSgocVcNLEZHQ0ozeSMiUGk/TzRHUClCU0heX-Api-Key: aAbBcC...xXyYzZ" -H "Content-Type: application/json" -d "{\"page_num\":1,\"page_size\":505,\"query\":{\"dataset\":[\"http://linked.data.gov.au/dataset/ausplots\"],\"feature_type\":[\"http://linked.data.gov.au/def/tern-cv/b311c0d3-4a1a-4932-a39c-f5cdc1afa611\"],\"observed_property\":[\"http://linked.data.gov.au/def/tern-cv/0bbd7fcd-0782-4efc-96e6-1f0f7669c655\"]}}"" |
Once the query has been defined appropriately, remove pagination to retrieve the full set of elements.
...