How to get a record of calls made from a particula...
# support
b
Hello, just a quick question, what API would you use to retrieve how many calls you have made with a particular Assistant ID ? i want to pull data that shows the number of calls made in a month?
Hello! šŸ‘‹ To retrieve the number of calls made with a particular Assistant ID in a month, you can use either of these two API approaches: ### 1. Using the
/call
Endpoint You can use the
/call
endpoint to filter and view calls by specific assistants:
Copy code
javascript
const response = await fetch('https://api.vapi.ai/call', {
  headers: {
    'Authorization': `Bearer YOUR_API_KEY`,
    'Content-Type': 'application/json'
  },
  params: {
    assistantId: 'your-assistant-id',
    page: 1,
    limit: 100
    // You'll need to add date filtering parameters
  }
});
### 2. Using the
/analytics
Endpoint (Recommended) This approach gives you more control over time ranges and data aggregation:
Copy code
bash
curl --location 'https://api.vapi.ai/analytics' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer your_vapi_access_token' \
--data '{
    "queries": [
        {
            "name": "getAnalyticsByAssistantID",
            "table": "call",
            "timeRange": {
                "start": "2024-03-01T00:00:00Z",
                "end": "2024-03-31T23:59:59Z",
                "step": "month"
            },
            "operations": [
                {
                    "operation": "count",
                    "column": "*"
                }
            ],
            "groupBy": [
                "assistantId"
            ]
        }
    ]
}'
Note: For monthly data, make sure to: - Set the
timeRange
to the specific month you want - Change the
step
to "month" - Use
"operation": "count"
instead of "sum" to count the number of calls āš ļø Important caveat: Some users have reported issues with the
/call
endpoint not properly returning logs filtered by Assistant ID, with endpoints returning empty arrays. The analytics endpoint might be more reliable for this purpose. Hope this helps! Let me know if you need any clarification. Sources:
b
hello thank you for your response, "operations": [ { "operation": "count", "column": "*" } for the column field value. is it meant to be a start (*) ?
what should the column value be?
m
Hey Bilal, refer to this message for your answer https://discord.com/channels/1211482211119796234/1211484481848873020/1349172928515801231 Let me know if that answers your question!