Paginate API results

Response returning hundreds of thousands of records at once can result in serious inconveniences for database, browser and web-server. A good way to prevent this is to paginate all results that return a list of items. This is what we do by default.

Result limiting

Requests that return multiple records will be paginated to 100 records by default.

Pagination

As mentioned above, by default the API will serve you the very first 100 records of requested data. You can specify further pages with the page parameter.

Note that page numbering is 1-based and that omitting the page parameter will return the first page.

1. Example – get first 100 records

# Get first 100 people (with or without param page)
$ http GET https://secure.yardman.io/api/people \
> Authorization:"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjozOSwiZXhwIjoxNTE5Mjk3MDIyfQ.R5UoAglylK2i5ov4qDH9bJUqt3qJh7uLVA11dLGlozg"

If the authorization token is valid you should get something similar to the following result:

HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Thu, 22 Mar 2018 06:52:30 GMT
ETag: W/"61f62acbc342312fa28f28b8f1835657"
Server: nginx/1.10.3 (Ubuntu)
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: 3e73c882-8e01-4be8-8b63-5783f9f00eff
X-Runtime: 0.016408
X-XSS-Protection: 1; mode=block

[
    {
        "driving_license_number": null,
        "email": null,
        "first_name": "Jakob",
        "id": 95,
        "last_name": "Adams",
        "mobile_phone": null,
        "notes": null,
        "status": "unknown"
    },
    {
        "driving_license_number": null,
        "email": null,
        "first_name": "Therese",
        "id": 77,
        "last_name": "Altenwerth",
        "mobile_phone": null,
        "notes": null,
        "status": "unknown"
    },
    # ... (cropped for clarity) ...
    {
        "driving_license_number": null,
        "email": null,
        "first_name": "Carey",
        "id": 83,
        "last_name": "Erdman",
        "mobile_phone": null,
        "notes": null,
        "status": "unknown"
    }
]

2. Example – get next 100 records

# Get next 100 people (mind the param page)
$ http GET https://secure.yardman.io/api/people page==2 \
> Authorization:"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjozOSwiZXhwIjoxNTE5Mjk3MDIyfQ.R5UoAglylK2i5ov4qDH9bJUqt3qJh7uLVA11dLGlozg"

If the authorization token is valid you should get something similar to the following result:

HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Thu, 22 Mar 2018 06:53:52 GMT
ETag: W/"2f798616dcec4d34824a20184ccff8fa"
Server: nginx/1.10.3 (Ubuntu)
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: 208e15ba-ba90-40ac-8d9c-dabcc0316737
X-Runtime: 0.015914
X-XSS-Protection: 1; mode=block

[
    {
        "driving_license_number": null,
        "email": null,
        "first_name": "Jared",
        "id": 51,
        "last_name": "Farrell",
        "mobile_phone": null,
        "notes": null,
        "status": "unknown"
    },
    {
        "driving_license_number": null,
        "email": null,
        "first_name": "Mabelle",
        "id": 120,
        "last_name": "Feeney",
        "mobile_phone": null,
        "notes": null,
        "status": "unknown"
    },
    # ... (cropped for clarity) ...
    {
        "driving_license_number": null,
        "email": null,
        "first_name": "Courtney",
        "id": 86,
        "last_name": "Kohler",
        "mobile_phone": null,
        "notes": null,
        "status": "unknown"
    }
]