Retrieve logs and analytics from call table
# support
e
The documentation does not work in python is there an updated doc ? @Vapi
@User
v
@Eeshita I'm here to help! If you're having trouble with the documentation for VAPI in Python, it could be that the documentation is outdated or there might be a specific issue you're encountering. Could you please provide more details about the problem you're facing? This will help me assist you better. If there's an updated version of the documentation, I'll make sure to guide you to it.
You can continue this conversation by mentioning me in the message.
e
Want to automate report for daily calls , need to get analytics @Vapi
v
Got it. Tagging @User for additional help.
@Eeshita That sounds like a great use case for VAPI! To automate a report for daily calls and get analytics, you would typically need to access call logs and analytics data through the API. If VAPI provides such functionality, you would use the appropriate endpoints to retrieve this data. Here's a general outline of the steps you might take: 1. Authenticate with the VAPI service to obtain access. 2. Use the API to fetch call logs for the desired time frame (daily). 3. Extract the relevant analytics data from the call logs. 4. Format this data into a report structure. 5. Automate this process to run at a scheduled time each day. If you need specific functions or commands to achieve this with VAPI, please let me know, and I can provide more detailed guidance. If there are any particular parameters or types of analytics you're interested in, that information would also be helpful.
e
Use the API to fetch call logs for the desired time frame (daily). @Vapi the documentation is outdated for python
v
@Eeshita I understand that you're looking for updated documentation to use the API for fetching call logs on a daily basis in Python. If the current documentation is outdated, I would recommend checking the official website or repository for the most recent updates. If you're unable to find the updated documentation there, you might want to reach out to the support team directly for assistance. In the meantime, if you're familiar with making HTTP requests in Python, you can typically use libraries such as
requests
to interact with APIs. Here's a generic example of how you might fetch call logs using Python:
Copy code
python
import requests
from datetime import datetime, timedelta

# Replace with your actual API endpoint and access token
api_endpoint = "https://api.yourvapi.com/call-logs"
access_token = "your_access_token"

# Set the desired time frame for the call logs
end_date = datetime.now()
start_date = end_date - timedelta(days=1)

# Format dates in the required format (e.g., ISO 8601)
start_date_str = start_date.isoformat()
end_date_str = end_date.isoformat()

# Prepare the headers and parameters for the API request
headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json"
}
params = {
    "start_date": start_date_str,
    "end_date": end_date_str
}

# Make the API request to fetch the call logs
response = requests.get(api_endpoint, headers=headers, params=params)

# Check if the request was successful
if response.status_code == 200:
    call_logs = response.json()
    # Process the call logs as needed
    print(call_logs)
else:
    print(f"Failed to fetch call logs: {response.status_code}")

# Note: This is a generic example and may need to be adjusted based on the actual API.
Please replace the placeholders with your actual API endpoint, access token, and any other necessary parameters. If you need further assistance with the specific API you're using, please let me know, and I'll do my best to help.
e
{'message': 'Cannot GET /call-logs', 'error': 'Not Found', 'statusCode': 404} @Vapi
v
@Eeshita The error message
{'message': 'Cannot GET /call-logs', 'error': 'Not Found', 'statusCode': 404}
indicates that the API endpoint for fetching call logs either does not exist at the specified path or there might be a typo in the URL. Here are a few steps you can take to resolve this issue: 1. **Check the Endpoint URL**: Ensure that the URL you are using matches the one provided in the API documentation. It's possible that the endpoint might have a different path or require a specific base URL. 2. **API Version**: If the API has different versions, make sure you are using the correct version in the URL. 3. **Base URL**: Verify that you have the correct base URL for the API. Sometimes APIs have different base URLs for different environments (e.g., staging vs. production). 4. **Documentation**: Since you mentioned that the documentation is outdated, it's possible that the endpoint has been changed or deprecated. If you can't find updated documentation online, you may need to contact the API provider's support team for the latest information. 5. **API Access**: Confirm that your API access token is valid and that your account has permission to access the call logs endpoint. If you're still unable to resolve the issue after checking these points, please reach out to the support team for the API you're using. They should be able to provide you with the correct endpoint and updated documentation. If there's anything else I can assist you with, please let me know!
s
Hey @Eeshita can you help me with issue your facing and which docs is not working for you?
e
@Shubham Bajaj i am using this url = f"https://api.vapi.ai/call/" to retrive calls but i am only able to get 100 call logs at once how do i get it for over 100 calls
@User
@Vapi
@User , please help wih this stuck from 2 days
n
I mean you just add a different limit than 100 to the params?
Copy code
python
params = {
    "start_date": start_date_str,
    "end_date": end_date_str,
    "limit": 250
}

response = requests.get(api_endpoint, headers=headers, params=params)
e
FYI , start date and end date seem to be invalid params.
s
At max you will get 100 call records, to get next 100 you need to use pagination. Do check the API response you will see the pagination parameters.
@Eeshita do let me know if you have difficulty getting next 100 records using pagination.
e
@Shubham Bajaj What kind of pagination ? page or cursor, tried both didn't work.
s
@Eeshita can you share the CURL?
e
this lets me fetch 1000 latest records curl -X GET "https://api.vapi.ai/call/?limit=1000" \ -H "Authorization: Bearer YOUR_TOKEN"
s
@Eeshita basically you filter out the data using created and updated parameters and using limit parameter on top of it you get your records.
example
curl -G https://api.vapi.ai/call?createdAtGt=2024-12-03T08%3A06%3A47.856Z&limit=0&createdAtLt=2024-12-03T08%3A08%3A18.007Z&createdAtGe=2024-12-03T08%3A08%3A26.673Z \ -H "Authorization: Bearer " \ --data-urlencode createdAtGt=2024-12-03T08:06:47.856Z \ -d limit=0 \ --data-urlencode createdAtLt=2024-12-03T08:08:18.007Z \ --data-urlencode createdAtGe=2024-12-03T08:08:26.673Z
4 Views