I am currently working on a Python script to fetch call engagements data from HubSpot for the previous day. I am facing difficulties in finding a suitable API endpoint that allows me to fetch data based on a specific date. I need help from the community to find the correct approach and solution for this task.
Objective:
My objective is to retrieve call engagements data for the previous day using the HubSpot API. The API should support filtering engagements based on their creation date. However, I am unable to find a direct API endpoint that allows me to specify a custom date range for fetching engagements.
Current Approach:
- I am using the HubSpot Python SDK to interact with the HubSpot API.
- I have tried using the “GET all engagements” endpoint with filters for the created date, but it seems that the API does not support filtering engagements based on a specific date.
- I have also attempted to use the “Search API” to apply filters for the “createdat” property within the desired date range. However, it appears that there is an issue with the PublicObjectSearchRequest class in the Python SDK, which is preventing me from using this approach as well.
Desired Solution:
I am seeking guidance and suggestions from the community on how to effectively fetch call engagements data for the previous day using the HubSpot API. Any insights, code examples, or alternative API endpoints that support date filtering would be greatly appreciated.
Relevant Code Snippet:
import hubspot
from datetime import datetime, timedelta
from pprint import pprint
# Replace “YOUR_HUBSPOT_API_KEY” with your actual HubSpot API key
api_client = hubspot.Client.create(api_key=“YOUR_HUBSPOT_API_KEY”)
def fetch_calls_for_previous_day():
# Calculate the date range for the previous day
specific_date = datetime.now() - timedelta(days=1)
start_timestamp = int((specific_date.replace(hour=0, minute=0, second=0, microsecond=0) - datetime(1970, 1, 1)).total_seconds() * 1000)
end_timestamp = int((specific_date.replace(hour=23, minute=59, second=59, microsecond=999999) - datetime(1970, 1, 1)).total_seconds() * 1000)
try:
# API request code with appropriate filters
# …
# Print or process the fetched call engagements data
# …
except hubspot.ApiException as e:
print(“Exception when calling CRM Search API: %s\n” % e)
return []
# Call the function to fetch call engagements for the previous day
calls_data = fetch_calls_for_previous_day()
pprint(calls_data)

