pagination with calls
# support
y
hello, I am Yousef. I am tying to fetch calls to show in my frontend, but I am facing difficulty implementing pagination. I just see a "limit" attribute that specify the number of record in the page, but how to provide another credentials to get the next and previous pages. please, help me understand the pagination mechansim.
v
Hello Yousef, I understand you're having difficulty implementing pagination for calls in your frontend. While I can confirm that Vapi has a "limit" attribute to specify the number of records per page, I don't have complete information about the additional parameters needed for next/previous pages. Have you checked the API Reference documentation at
/api-reference/calls/list
(GET List Calls endpoint)? This would likely contain the specific pagination parameters you need beyond the "limit" attribute.
y
@Vapi Support Bot I am not sure if the other attributes helps in pagination or not. please help me with example
v
Based on the information I found, Vapi uses cursor-based pagination rather than traditional page numbers. Here's how you can implement pagination with the GET List Calls endpoint: For your first page:
Copy code
GET https://api.vapi.ai/call?limit=100
For subsequent pages, use timestamp parameters:
Copy code
GET https://api.vapi.ai/call?limit=100&createdAtLt=2024-05-01T00:00:00Z
Where
createdAtLt
is the timestamp of the oldest record from your previous page. This fetches the next 100 records created before that timestamp. For previous pages, use:
Copy code
GET https://api.vapi.ai/call?limit=100&createdAtGt=2024-05-02T00:00:00Z
Where
createdAtGt
is the timestamp of the newest record on your current page. Does this approach work for your implementation? Sources: - [API Reference](https://docs.vapi.ai/api-reference/) - [API Reference for List Calls](https://docs.vapi.ai/api-reference/calls/list)
y
suppose if there are 200 calls are created at the same timestamp, if the limit is 100, does it fetch the other 100 calls?
k
Use limit to set how many call records to fetch and page to select which set to retrieve like page=2 for the next set, increment or decrement page to paginate through results.
Yes, if there are 200 calls and limit=100, the API will return the first 100 calls on page=1 and the remaining 100 on page=2.