Skip to main content
Question

Send level data from email activities endpoint

  • April 3, 2026
  • 1 reply
  • 4 views

wineandsong

I’m trying to retreive raw data for each email a contact has been sent. This would result in a large table with millions of rows, since we send millions of emails.

I thought that email activities would be the end point that need for this and wrote a python script (below). This ran for a while and when it concluded I had only tens of thousands of rows, not millions as expected.

Have I misunderstood what email activities is? How can I retreive send level data per contact_id? One record per instance of an email being sent across any and all campaigns.

import requests
import pandas as pd
import sys

if len(sys.argv) < 2:
print("Usage: python email_activities.py <API_KEY>")
sys.exit(1)

API_KEY = sys.argv[1]
BASE_URL = "https://<our org name>.api-us1.com/api/3"

headers = {
"Api-Token": API_KEY,
"Accept": "application/json"
}

all_activities = []
offset = 0
limit = 100

while True:
response = requests.get(
f"{BASE_URL}/emailActivities",
headers=headers,
params={"limit": limit, "offset": offset}
)
data = response.json()
activities = data.get("emailActivities", [])
if not activities:
break
all_activities.extend(activities)
print(f"Fetched {len(all_activities)} records so far...")
offset += limit

print(f"\nTotal records: {len(all_activities)}")

df = pd.DataFrame(all_activities)
df.to_csv("email_activities.csv", index=False)
print("Saved to email_activities.csv")
print(f"\nColumns: {list(df.columns)}")
print(f"\n{df.head()}")

 

1 reply

Ryan_ActiveCampaign
Forum|alt.badge.img

Hi wineandsong! I’d be glad to help look into this for you. To help make sure that I am fully understanding what information you are looking for, can you expand a bit on exactly what information you are trying to obtain when you say “raw data for each email a contact has been sent.” Do you mean that you are looking for the campaign ID and send details such as date/time? Or is there more specific information that you’re trying to pull? Once I have a clear vision on what you’re looking for, I’ll do some digging and see what the best way to get that via API would be!