Menu

GeoDB Cities API

Pagination

Collection Response Format

Any collection request will have the following basic response format:

{
  metadata: {
    currentOffset: ZERO_BASED_INDEX_OF_THE_FIRST_RESULT,
    totalCount: TOTAL_NUMBER_OF_RESULTS
  }
  results: [
    {
      result1
    },
    {
      result2
    },
    ...
  ]
}

Pagination Links

If you are making a collection request and the number of results exceeds the requested limit (page size), you will see the following additional elements in the response:

{
  ...
  "links":[
    {
      "rel":"first",
      "href":"/link/to/first/page/of/results"
    },
    {
      "rel":"prev",
      "href":"/link/to/previous/page/of/results"
    },
    {
      "rel":"next",
      "href":"/link/to/next/page/of/results"
    },
    {
      "rel":"last",
      "href":"/link/to/last/page/of/results"
    }
  ]
}

These links adhere to the HATEOAS format and should be self-explanatory.

Notes:

  • The prev/next links will be generated if contextually appropriate. Meaning, there will be no prev or next if you're already on the first or last page, respectively.
  • Specifying an offset that goes beyond the last page of results will simply return the last page of results.
  • You may optionally turn off HATEOAS link generation by setting the hateoasMode request parameter to false. See the API docs for details.