How to Export Mixpanel Data with the Raw Export and Query APIs

Mixpanel’s interface covers most analysis, but sometimes you need data outside it: to load events into a warehouse, feed a BI dashboard, back up a project, or run a custom model. Mixpanel offers several APIs for this. The two most used are the Raw Event Export API, which returns every event as stored, and the Query API, which returns the results of reports such as Insights, Funnels and Retention.

This guide explains when to use each, how to authenticate, how to make requests, rate limits, and how to process the results correctly.

Which export method to use

Mixpanel’s export docs group the options like this:

You needUse
Raw events with all properties and original timestampsRaw Event Export API (or Data Pipelines for continuous export)
User profilesEngage API
Group profilesEngage API with a data_group_id
Report results (Insights, Funnels, Retention)Query API
Ongoing sync to a warehouse or bucketData Pipelines (post 20)
A user’s personal data for a privacy requestGDPR retrieval API (post 33)

Rule of thumb: if you need numbers that match a saved report, use the Query API. If you need every row to compute something yourself, use Raw Event Export.

Step 1: Create a service account

Mixpanel recommends service accounts for API access.

  1. In organization settings, create a service account (Owners and Admins can manage them; see post 34).
  2. Give it access to the project with an appropriate role.
  3. Save the username and secret.
  4. Note the project ID from project settings. With a service account, you include project_id in every request.

If your project uses classified data (Data Views and classification), the service account needs permission to access it, or classified properties won’t be returned.

Authentication is HTTP Basic Auth with the service account username as the user and the secret as the password. Older documentation also shows project secret authentication; service accounts are the recommended method.

Step 2: Pick the right server

Data residencyRaw Event Export hostQuery API host
USdata.mixpanel.commixpanel.com/api/query
EUdata-eu.mixpanel.comeu.mixpanel.com/api/query
Indiadata-in.mixpanel.comin.mixpanel.com/api/query

Confirm hosts in Mixpanel’s API reference for your region; calling the wrong region returns errors or no data.

Part A: Raw Event Export API

Making a request

The endpoint is /api/2.0/export. from_date and to_date are required and inclusive, in YYYY-MM-DD format.

curl -G 'https://data.mixpanel.com/api/2.0/export' \
  -u 'SERVICE_ACCOUNT_USER:SERVICE_ACCOUNT_SECRET' \
  --data-urlencode 'project_id=1234567' \
  --data-urlencode 'from_date=2026-11-01' \
  --data-urlencode 'to_date=2026-11-01' \
  --data-urlencode 'event=["purchase_completed"]' \
  -H 'Accept-Encoding: gzip' --compressed \
  -o events_2026-11-01.jsonl

Useful parameters:

ParameterPurpose
from_date, to_dateRequired date range (inclusive)
eventJSON array of event names to export; omit for all events
whereFilter expression on properties
limitMaximum events returned (Mixpanel’s docs cap it at 100,000)
project_idRequired with service account auth

Add Accept-Encoding: gzip to compress large responses.

Response format

The response is JSONL: one JSON event per line, with the event name and a properties object including distinct_id, time and $insert_id.

{"event":"purchase_completed","properties":{"time":1761955200,"distinct_id":"user_123","$insert_id":"purchase_ORD-1","revenue":49.0}}

A Python export script

import os, json, requests, datetime as dt

USER = os.environ['MP_SA_USER']
SECRET = os.environ['MP_SA_SECRET']
PROJECT_ID = os.environ['MP_PROJECT_ID']

def export_day(day):
    resp = requests.get(
        'https://data.mixpanel.com/api/2.0/export',
        params={'project_id': PROJECT_ID, 'from_date': day, 'to_date': day},
        auth=(USER, SECRET),
        headers={'Accept-Encoding': 'gzip'},
        stream=True, timeout=600)
    resp.raise_for_status()
    with open(f'events_{day}.jsonl', 'wb') as f:
        for chunk in resp.iter_content(chunk_size=1 << 20):
            f.write(chunk)

start = dt.date(2026, 11, 1)
for i in range(7):
    export_day((start + dt.timedelta(days=i)).isoformat())

Export one day per request for large projects. It keeps responses manageable and makes retries simple. Mixpanel’s mixpanel-utils Python module also includes an export_events helper.

Rate limits

Mixpanel documents the Raw Event Export API limits as 60 queries per hour, 3 queries per second, and up to 100 concurrent queries. Over the limit, you get a 429. Plan large backfills over several hours, and back off on 429s.

Processing exported events correctly

Raw exports contain data as ingested, which differs from what reports show in three important ways:

  1. Deduplication: query-time deduplication isn’t applied. Deduplicate on event name, distinct ID, time and $insert_id (post 3).
  2. Identity: events carry the distinct ID they were sent with. To match unique user counts in the UI, resolve IDs with Mixpanel’s identity mappings (available through Data Pipelines) (post 2).
  3. Hidden events and custom definitions: hidden events are still exported, and custom events or custom properties don’t exist in raw data (post 16).

Also note timestamps: newer projects store raw data in UTC.

Some projects on older Free plans don’t include raw export; Mixpanel’s docs say the API returns a plan error in that case and suggest contacting support.

Part B: Query API (report results)

The Query API returns aggregated results similar to what you see in reports.

Query a saved Insights report

The most practical approach: build the report in Mixpanel (post 28), save it, and query it by its ID. Mixpanel recommends this over the older Segmentation endpoint, which is in maintenance mode.

  1. Open the saved Insights report and copy its bookmark ID from the URL.
  2. Call the Insights query endpoint:
curl -G 'https://mixpanel.com/api/query/insights' \
  -u 'SERVICE_ACCOUNT_USER:SERVICE_ACCOUNT_SECRET' \
  --data-urlencode 'project_id=1234567' \
  --data-urlencode 'bookmark_id=98765432'

The response contains the series and values of the report as saved. Change the report in Mixpanel and the API output changes with it, so definitions stay in one place.

Other Query API endpoints

Mixpanel’s Query API reference includes endpoints for Funnels, Retention (with birth for first-time and compounded for recurring retention), Engage (profiles) and others. Check each endpoint’s parameters in the reference.

Query API rate limits

Mixpanel documents the Query API at 60 queries per hour with up to 5 concurrent queries. Cache results in your own system rather than calling the API on every dashboard load.

Part C: Exporting profiles

Use the Engage API to page through user profiles, optionally filtered by a where expression or cohort. For group profiles, pass the group’s data_group_id. Mixpanel lists the Engage API at 60 queries per hour and 5 concurrent queries.

Exporting with Claude

If you use Mixpanel’s MCP server with Claude, you can run report-style queries in plain language, which is handy for one-off questions. For repeatable exports into other systems, use the APIs above or Data Pipelines.

Common issues

ProblemCause
401 / 403Wrong credentials, missing project_id, or service account lacks project access
Empty responseWrong regional host, or no events in the date range
429Rate limit reached; slow down and retry with backoff
Counts higher than reportsNo deduplication or identity resolution applied
Missing propertiesClassified data without permission, or custom properties (not in raw data)

Summary

Create a service account, use the right regional host, and choose the API by need: Raw Event Export for every event (JSONL, one day per request, deduplicate and resolve identity yourself), the Insights Query API for saved report results, and the Engage API for profiles. Respect the rate limits and use Data Pipelines for ongoing large-scale exports.

Sources

GET EXPERT ANALYTICS HELP

Need help getting reliable answers from Mixpanel?

Tell us about your tracking, funnels, retention, or reporting challenge. Optizent can help you implement, audit, and use Mixpanel with confidence.

We will use these details to respond to your request. Please do not include passwords, account access, or customer data.