Pagination
By default, all index (i.e., GET /resources) calls to our API will be paginated. To paginate the API, you can use thelimit and offset query parameters.
Basic pagination
Default behavior
- Default limit: 20 records
- Maximum limit: 100 records
- Default offset: 0
- Default order:
['createdAt', 'DESC'](newest first)
Pagination response
Paginated responses include metadata to help with navigation:Query parameters
Ordering
You can customize the sort order using theorder parameter:
ASC- Ascending orderDESC- Descending order
Filtering
Use thefilter parameter to restrict results:
Depending on your HTTP client, you may need to URL encode the JSON filter object.
Scopes
The Perch API uses scopes to simplify common or complicated queries:withDeleted- Include soft-deleted recordsactive- Only active (non-deleted) records
Including related data
Use theinclude parameter to join related resources:
Soft deletion
Many resources in our system support soft-deletion, which we call “paranoid” resources. This means that records will not be removed from the database, but instead get a timestamp value set to the record’sdeletedAt column.
Working with soft-deleted records
By default, deleted records are not returned:withDeleted scope:
Lead conversion and soft deletion
When a lead converts to a client profile:- The
convertedAttimestamp is set - The
deletedAttimestamp is set (automatically archived) - Any associated plans are created and linked
withDeleted scope:
Best practices
- Use appropriate page sizes - Start with the default (20) and adjust based on your needs
- Implement client-side caching - Cache results to reduce API calls
- Use filters efficiently - Filter on the server side rather than fetching all records
- Include related data when needed - Use
includeto reduce round trips - Handle large datasets - Use pagination rather than trying to fetch all records at once
- Combine parameters effectively - Use filtering, ordering, and pagination together