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.

Example Workflow

  1. Initial Request:
    • Send a GET request to the desired endpoint (e.g., /drivers) with a limit parameter to specify the maximum number of results per page.
    • Example: GET /drivers?limit=50
  2. Checknext in Response:
    • After receiving the response, inspect the next field. If it contains a cursor value, it indicates that additional data is available.
  3. Subsequent Requests:
    • Use the next cursor value as the cursor parameter in the next request.
    • Example: GET /drivers?limit=50&cursor=eyJvZmZzZXQiOjEwMH0
  4. Repeat:
    • Continue making requests until the next field is absent or null, indicating that all data has been retrieved.

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 fornext :
    • Always inspect the next field in the response to determine if more data is available.
  • Use the Cursor:
    • Pass the cursor value in the cursor query parameter of subsequent requests.
  • Iterate Until Complete:
    • Continue fetching pages until the next field is null or absent.

Endpoint Support for Pagination

Pagination is supported across the following endpoints:

EndpointDescription
/connectionsRetrieve a list of connections.
/driversRetrieve a list of drivers.
/safety-eventsRetrieve all safety events within a date range.
/tripsRetrieve all trips within your account.
/vehiclesRetrieve 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.
  • 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.