Pagination
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
All endpoints that return a list of items support pagination to ensure optimal performance and user experience. This API uses limit/offset pagination, which is one of the most widely used methods that allows you to retrieve large datasets in manageable chunks.
Parameters
Section titled “Parameters”limit (optional, default: 10)
Section titled “limit (optional, default: 10)”Specifies the number of objects to return per page. Must be between 1 and 100.
Example: limit=25
offset (optional, default: 0)
Section titled “offset (optional, default: 0)”Specifies the number of records to skip before starting to return results. Used to navigate to specific pages.
Example: offset=50 (skips the first 50 records)
page (optional, alternative to offset)
Section titled “page (optional, alternative to offset)”Page number for easier navigation. When provided, the offset is automatically calculated as (page - 1) × limit.
Example: page=3 with limit=10 is equivalent to offset=20
Request Examples
Section titled “Request Examples”# Get first 10 items (default)curl -X GET "https://app.newtrition-data.com/api/v1/search?query=Brot"
# Get 25 items starting from the beginningcurl -X GET "https://app.newtrition-data.com/api/v1/search?query=Brot?limit=25"
# Get page 3 with 10 items per page (items 21-30)curl -X GET "https://app.newtrition-data.com/api/v1/search?query=Brot?page=3&limit=10"
# Get 15 items starting from the 45th recordcurl -X GET "https://app.newtrition-data.com/api/v1/search?query=Brot?limit=15&offset=45"Response Format
Section titled “Response Format”{ "data": [ { "id": "item_123", "name": "Example Item" } ], "pagination": { "limit": 10, "offset": 20, "page": 3, "total_count": 150, "total_pages": 15, "has_next": true, "has_previous": true }, "links": { "self": "https://app.newtrition-data.com/api/v1/search?query=Brot&page=3&limit=10", "first": "https://app.newtrition-data.com/api/v1/search?query=Brot&page=1&limit=10", "last": "https://app.newtrition-data.com/api/v1/search?query=Brot&page=15&limit=10", "next": "https://app.newtrition-data.com/api/v1/search?query=Brot&page=4&limit=10", "previous": "https://app.newtrition-data.com/api/v1/search?query=Brot&page=2&limit=10" }}Response Fields
Section titled “Response Fields”data (array)
Section titled “data (array)”An array containing the actual response elements for the current page.
pagination (object)
Section titled “pagination (object)”Contains metadata about the current pagination state:
limit(number): Number of items requested per pageoffset(number): Number of items skippedpage(number): Current page numbertotal_count(number): Total number of items availabletotal_pages(number): Total number of pages availablehas_next(boolean): Whether there are more pages after the current onehas_previous(boolean): Whether there are pages before the current one
links (object)
Section titled “links (object)”Pre-constructed URLs for easy navigation:
self: URL for the current pagefirst: URL for the first pagelast: URL for the last pagenext: URL for the next page (null if on last page)previous: URL for the previous page (null if on first page)
Search Endpoint Caveat
Section titled “Search Endpoint Caveat”For GET /api/v1/search and GET /api/v2/search, results are grouped to reduce near-duplicates.
Because of that, deep-pagination metadata should be treated as navigation guidance instead of an exact page-count guarantee.
pagination.total_countmay be approximate for deep pagespagination.total_pagesmay be approximate for deep pageslinks.lastshould not be used to precompute an exact final page for search results
For search clients, prefer sequential navigation with links.next and links.previous.
For shallow pagination, the metadata is still useful, but clients should avoid assuming that very deep search pages have exact final-page semantics.
Best Practices
Section titled “Best Practices”For API Consumers
Section titled “For API Consumers”- Always specify a limit to ensure consistent results and avoid relying on default values
- Use the provided links in the response for navigation instead of constructing URLs manually
- For search endpoints, prefer sequential navigation with
next/previousinstead of relying on an exact final page - Handle edge cases like empty pages or when
has_nextis false - Cache pagination metadata carefully; for search endpoints, deep-page counts are best treated as approximate
Error Handling
Section titled “Error Handling”When pagination parameters are invalid, the API returns appropriate error responses:
{ "code": "INVALID_PAGINATION", "message": "Limit must be between 1 and 100", "details": { "parameter": "limit", "provided_value": 150, "valid_range": "1-100" }}Performance Considerations
Section titled “Performance Considerations”- Limit size: Larger page sizes reduce the number of requests but increase response time and memory usage
- Deep pagination: Very high offset values may result in slower response times
- Sorting: Paginated results are consistently ordered.