Efficient data handling: Mastering Pagination in API requests

When you interact with our API, especially on endpoints that fetch multiple items like Get users and Get shifts, you'll encounter a system designed to manage large sets of data effectively: Pagination.
This system is crucial for enhancing performance and usability when dealing with extensive lists of resources.

Key pagination parameters: limit and offset

Understanding and using two main parameters, limit and offset, is essential for navigating through these lists:

  1. limit Parameter: This determines the number of items you'll receive in your response. Think of it as setting the maximum number of items on each "page" of data. If you don't specify this, it defaults to 10 items, ensuring manageable data chunks.
  2. offset Parameter: Imagine flipping through a book to reach a specific page. The offset parameter works similarly. It lets you specify the starting point in the list of resources. This way, you can jump directly to the part of the data you're interested in.

📘

Practical example

Let's put these parameters into a real-world context:

  • Imagine your account has 30 users
  • You want to view these users in smaller groups rather than all at once
  • You decide to use a limit of 10
  • On your first request, you set an offset of 0, which gives you users 1 to 10
  • For your next request, you set an offset of 10, and you receive users 11 to 20
  • This method continues, allowing you to efficiently navigate through all the users

By using these pagination parameters, you can efficiently access and manage large lists of resources through our API, ensuring a smooth and scalable interaction with our data.

Example: Making a paginated API request

curl --request GET \
     --url 'https://app.connecteam.com/external-api/forms/v1/forms?limit=10&offset=0'\
     --header 'accept: application/json' \
     --header 'X-API-KEY: <API_KEY>'

This URL is configured to retrieve the initial 10 items from the list, beginning from the start (offset set to 0).