Pagination

The Appointedd HTTP API uses range-based pagination for most requests that return more than one item in its response. We've designed it to be as simple to use from an API user perspective without having to know about how range-based pagination works.

All endpoints that are paginated will return the following properties in their response along with the data items:

  • total - Number of items in your organisation that matches your current request.
  • prev - An ID that can be used to retrieve the previous page from your current page. If there is no previous page (i.e. the current page is the first page), this will be set to null.
  • next - An ID that can be used to retrieve the next page from your current page. If there is no next page (i.e. the current page is the last page), this will be set to null.

All endpoints that are paginated will accept the following parameters in their request:

  • limit - Maximum number of items to return in a page to your request. Accepts integers ranging from 1 to 100 and defaults to 10 if not set.
  • start - An ID of the first document on a page. You can set this to the ID in the next property of your current page to get the next page in your dataset.
  • end - An ID of the last document on a page. You can set this to the ID in the prev property of your current page to get the previous page in your dataset.

📘

Maximum Items Per Request

The maximum number of items you can return at once from any paginated endpoint is 100. Whilst you can ignore pagination if you have less than that number, we recommend you add pagination support as your requests will not work correctly should you pass that number.

Retrieving all customers in your organisation with pagination

The example below shows how you can retrieve all of the customers in your organisation with pagination support in various programming languages. To get the request to work, replace <YOUR_API_KEY> with your Appointedd organisation's API key.

// README:
// 1. Save this to a file called `index.js`.
// 2. Fill out details in square brackets (<>).
// 3. Run `npm install axios` in the same directory.
// 4. Run `node index.js` in the same directory.
const axios = require("axios").default;

const main = async () => {
  let customers = [];
  let nextId = undefined;
  let hasMore = true;

  while (hasMore) {
    const response = await axios.get(
      "https://api.appointedd.com/v1/customers",
      {
        headers: {
          "X-API-KEY": "<YOUR_API_KEY>",
        },
        params: {
          start: nextId,
          limit: 100,
        },
      }
    );

    const page = response.data;

    customers.push(...page.data);

    if (page.next === null) hasMore = false;
    else nextId = page.next;
  }

  console.log(customers);
};

main();

What’s Next