Get started
API conventions

Pagination

Pagination

Every Map Studio API listing of what you create pages by cursor. Ask for a page with limit, then send the page's next_cursor back as cursor until it reads null.

CURSOR=""
while : ; do
  PAGE=$(curl -s "https://api.mountaya.com/v1/itineraries?limit=50${CURSOR:+&cursor=$CURSOR}" \
    -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY")
  echo "$PAGE" | jq -r '.data[].name'
  CURSOR=$(echo "$PAGE" | jq -r '.extensions.metadata.pagination.next_cursor // empty')
  [ -z "$CURSOR" ] && break
done

Each page reports where the next one starts. Here, a page of limit=2:

Response (abridged)
{
  "data": [
    { "id": "44025509-41bc-4038-ac47-05ecbe9a6035", "name": "Docs Tour du Mont-Blanc" },
    { "id": "2660b62b-99ba-4ac8-b269-e034b551e17f", "name": "Docs quickstart 802195" }
  ],
  "extensions": {
    "metadata": {
      "pagination": {
        "limit": 2,
        "next_cursor": "eyJ2IjoxLCJzIjoiLXVwZGF0ZWRfYXQiLCJrIjpbIjIwMjYtMTEtMDlUMDk6MTU6MTUuMTczNTU1WiIsIjI2NjBiNjJiLTk5YmEtNGFjOC1iMjY5LWUwMzRiNTUxZTE3ZiJdLCJmIjoiWDJ3R2hWcms4ZjlfbzJGWiJ9"
      }
    }
  }
}

limit runs from 1 to 100, and defaults to 50. Only a null cursor ends the listing: a short page, even an empty one, can have pages after it.

Filter and sort

Filters are query parameters named after the field they narrow, such as status or is_private, and they combine. sort takes one key, descending with a leading -, such as sort=-updated_at.

To mirror a listing, record when you last read it. Then ask for updated_since with sort=updated_at to read only what changed.

Next steps

Last updated