How to list more than 10 items when listing information via API?
Problem Statement
This article explains how to control how many items list APIs return and how to page through results beyond the default limit.
Related Scenarios
- What is the maximum number of items returned by list APIs?
- How do I use the offset parameter with list APIs?
Solution
List APIs (Subscriptions, Plans, Addons, and similar) return 10 items by default. To change the number of items per response, pass the limit parameter (maximum 100). To retrieve more than 100 items, use the offset parameter with the next_offset value from the previous response to fetch the next page.
Steps to Set It Up
Increase the limit (up to 100): Include limit in your request. Example (addons, limit 15):
curl https://{site}.chargebee.com/api/v2/addons \
-G \
-u {site_api_key}: \
--data-urlencode limit="15" \
--data-urlencode type[is]="on_off" \
--data-urlencode status[is]="active"Page through all results: Use limit=100 and, for each response, use the returned next_offset as offset in the next request until next_offset is empty. Add a short delay between calls to stay within rate limits (for example, 100 requests per minute).
Example pattern (pseudocode): call the list API with limit=100 and offset; read next_offset from the response; repeat with that value as offset until next_offset is empty.
Note
List operations are eventually consistent, so a list response might not reflect a recent change. To read your own writes, call the resource's retrieve endpoint instead. For more information, see Read consistency.
For full details and parameters, see the Subscriptions list API and the general API documentation.
Was this article helpful?