Pagination
The Manifold API employs pagination to manage large datasets efficiently. Updated pagination functionality ensures consistent retrieval of data across multiple endpoints, such as connections, drivers, trips, vehicles, and more.
Query Parameters
limit
:- Description: Specifies the maximum number of items to return in a single page.
- Default: 50 if not explicitly defined.
- Example:
limit=100
cursor
:- Description: A token that indicates the starting point for the next page of results.
- Example:
cursor=eyJvZmZzZXQiOjEwMH0
Response Fields
data
:- Description: Contains an array of objects relevant to the requested endpoint (e.g., list of connections, drivers, vehicles, etc.).
next
:- Description: If more results are available, this field provides the cursor value for the next page. Use this value as the
cursor
parameter in subsequent requests. - Note: If the
next
field is absent or null, there are no additional pages.
- Description: If more results are available, this field provides the cursor value for the next page. Use this value as the
Example Workflow
- Initial Request:
- Send a
GET
request to the desired endpoint (e.g.,/drivers
) with alimit
parameter to specify the maximum number of results per page. - Example:
GET /drivers?limit=50
- Send a
- Check
next
in Response:- After receiving the response, inspect the
next
field. If it contains a cursor value, it indicates that additional data is available.
- After receiving the response, inspect the
- Subsequent Requests:
- Use the
next
cursor value as thecursor
parameter in the next request. - Example:
GET /drivers?limit=50&cursor=eyJvZmZzZXQiOjEwMH0
- Use the
- Repeat:
- Continue making requests until the
next
field is absent or null, indicating that all data has been retrieved.
- Continue making requests until the
Example Response
{
"status": 200,
"message": "Success",
"data": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "John Doe",
"connectionId": "connection123",
"email": "[email protected]"
}
],
"next": "eyJvZmZzZXQiOjEwMH0" // Cursor for the next page of results
}
Handling Pagination in Your Client
To effectively manage paginated responses in your application:
- Check for
next
:- Always inspect the
next
field in the response to determine if more data is available.
- Always inspect the
- Use the Cursor:
- Pass the cursor value in the
cursor
query parameter of subsequent requests.
- Pass the cursor value in the
- Iterate Until Complete:
- Continue fetching pages until the
next
field is null or absent.
- Continue fetching pages until the
Endpoint Support for Pagination
Pagination is supported across the following endpoints:
Endpoint | Description |
---|---|
/connections | Retrieve a list of connections. |
/drivers | Retrieve a list of drivers. |
/safety-events | Retrieve all safety events within a date range. |
/trips | Retrieve all trips within your account. |
/vehicles | Retrieve a list of vehicles. |
Best Practices for Pagination
- Set an Appropriate Limit:
- Use the
limit
parameter to optimize the size of each page. A smaller limit reduces response time but increases the number of requests.
- Use the
- Cache Cursor Values:
- Retain cursor values for audit logs or debugging purposes, especially if your application experiences interruptions.
- Use Concurrency Judiciously:
- Fetch multiple pages concurrently only if supported by your application logic to improve performance.
Updated 7 days ago