How to reduce api response time?
# support
h
Hello, I am developing a dashboard for customers using VAPI APIs in PHP. I am fetching the call logs of multiple assistants at once, but it is taking a lot of time to fetch the data. Is there any way to reduce the response time of the API?
v
Hi there! 👋 I understand you're experiencing slow response times when fetching call logs for multiple assistants in your PHP dashboard. I can definitely help with some strategies to improve this! While I don't have PHP-specific implementation details for VAPI, I can share several effective approaches to reduce API response time when fetching call logs: ### 1. Use Filtering and Pagination Utilize the API's filtering and pagination parameters to limit the amount of data returned:
Copy code
https://api.vapi.ai/logs?assistantId=YOUR_ASSISTANT_ID&page=1&limit=100
According to the [VAPI API documentation](https://docs.vapi.ai/api-reference/logs/get), you can use parameters like: -
assistantId
to filter by specific assistant -
page
for pagination (defaults to 1) -
limit
to control results per page (defaults to 100, max 1000) ### 2. Implement Date Range Filtering Narrow down results by specifying date ranges:
Copy code
https://api.vapi.ai/logs?createdAtGte=2025-03-01T00:00:00Z&createdAtLte=2025-03-21T00:00:00Z
This significantly reduces the data being processed and transferred. ### 3. Consider Using Webhooks Instead of repeatedly polling for logs, implement webhooks to receive real-time updates:
Copy code
serverMessages: ['end-of-call-report']
According to [VAPI documentation](https://docs.vapi.ai/server-url/events), this approach sends you an end-of-call report after each call, containing all call artifacts including transcript, call ID, and recording URLs. ### 4. Use the Analytics API with Grouping The Analytics API allows you to filter and group data by `assistantId`: ``` curl --location 'https://api.vapi.ai/analytics' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_TOKEN' \ --data '{ "queries": [ { "name": "getAnalyticsByAssistantID", "table": "call", "timeRange": { "start": "2025-01-01T00:00:00Z", "end": "2025-03-21T23:59:59Z",
"step": "month" }, "operations": [ { "operation": "sum", "column": "cost" } ], "groupBy": [ "assistantId" ] } ] }' ``` ### 5. Implement Caching Store frequently accessed data to reduce the number of API calls needed. ### 6. Batch Requests Combine multiple requests into a single API call where possible. ### 7. Validate Assistant IDs Ensure all
assistantId
values are valid to avoid unnecessary failed requests. ### 8. Check for Concurrency Limits Make sure you're not exceeding any concurrency limits that might be affecting performance. Would you like more details on any of these approaches or help with implementing a specific solution? Sources: - [General techniques for API response time optimization](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336685825227755591) - [How to optimize API response time for VAPI APIs](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336685825227755591) - [Best practices for fetching call logs efficiently](https://docs.vapi.ai/api-reference/logs/get) - [How to efficiently fetch call logs of multiple assistants at once](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1331285157088333955)
@Vapi
k
Hey Hasan, There is no way to reduce the time it takes to get the API to get the call logs related to an assistant. Instead, what you can do from now on is store the call logs related to each call and the assistant using the end-of-call report server message or server event. This will help you reduce the time and get real-time updates. Like right after the end of the call, you will have the complete call data in your database. This will eventually solve your problem, but yes, once you have to use call logs API.
2 Views