Advanced Topics

Advanced Topics

Pagination

To keep the HTTP responses from being too large, when the GO API returns a JSON list it will only
send the first "page" of items. The list_attributes object in the returned response object
contains three fields:

  • limit: the number of items in the returned list; you can think of this as the "page size"
    (int)
  • offset: the array index of the first item in the returned list (int)
  • total: the total number of items on the server (int)

You can control both the page size and what element to start at using query parameters on the URL.
For example, this URL:

GET /projects?limit=100&offset=0

is the default. The request will return at most 100 Project objects, starting with the first one.
The returned object might look like this:

{
        "data": "...",
        "list_attributes": {
            "limit": 100,
            "offset": 0,
            "total": 123
        },
        "status": 200
    }

This indicates that 100 items were retrieved and that there are 23 more items. You should repeat
your GET operation, starting at the "next page":

GET /projects?limit=100&offset=100

This second returned object should look like this:

{
        "data": "...",
        "list_attributes": {
            "limit": 100,
            "offset": 100,
            "total": 123
        },
        "status": 200
    }

Whenever a request returns a list of objects, your code must always check to see if additional
requests are required to fetch the remaining data.

Alternatively, you can use ?limit=-1 to request all items to be returned. For production-scale
projects, this may produce very large outputs.