Compliance APIs
Event Export
Export raw event data
GET
/
api
/
2.0
/
export
Event Export
curl --request GET \
--url https://data.mixpanel.com/api/2.0/exportimport requests
url = "https://data.mixpanel.com/api/2.0/export"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://data.mixpanel.com/api/2.0/export', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://data.mixpanel.com/api/2.0/export",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://data.mixpanel.com/api/2.0/export"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://data.mixpanel.com/api/2.0/export")
.asString();require 'uri'
require 'net/http'
url = URI("https://data.mixpanel.com/api/2.0/export")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyRaw Event Export
Export raw event data as JSON for custom processing and analysis.Base URL
https://data.mixpanel.com/api/2.0/export
Authentication
Use Project Secret with HTTP Basic Auth.Download Data
Export events within a date range.integer
Required when using service account authentication
string
required
Start date in
yyyy-mm-dd format (inclusive)Interpreted as UTC timezone for projects created after January 1, 2023string
required
End date in
yyyy-mm-dd format (inclusive)integer
Maximum number of events to return (max: 100,000)
string
Event name(s) to export, encoded as JSON arrayExample:
["Signed Up", "Purchase"]string
Expression to filter events
boolean
Export timestamps with millisecond precisionDefault:
false (second precision)string
Set to
gzip to compress the responseExample Request
curl "https://data.mixpanel.com/api/2.0/export?from_date=2024-01-01&to_date=2024-01-31" \
-u YOUR_PROJECT_SECRET: \
-H "Accept-Encoding: gzip"
import requests
from requests.auth import HTTPBasicAuth
response = requests.get(
'https://data.mixpanel.com/api/2.0/export',
auth=HTTPBasicAuth('YOUR_PROJECT_SECRET', ''),
params={
'from_date': '2024-01-01',
'to_date': '2024-01-31',
'event': '["Signed Up", "Purchase"]'
},
headers={'Accept-Encoding': 'gzip'}
)
# Response is newline-delimited JSON
for line in response.text.split('\n'):
if line:
event = json.loads(line)
print(event)
Response
Returns newline-delimited JSON (JSONL):{"event":"Signed Up","properties":{"time":1602611311,"$insert_id":"hpuDqcvpltpCjBsebtxwadtEBDnFAdycabFb","mp_processing_time_ms":1602625711874,"distinct_id":"user123","$email":"user@example.com"}}
{"event":"Purchase","properties":{"time":1602787121,"$insert_id":"jajcebutltmvhbbholfhxtCcycwnBjDtndha","mp_processing_time_ms":1602801521561,"distinct_id":"user123","amount":29.99,"currency":"USD"}}
Rate Limits
The Export API has strict rate limits:
- 60 queries per hour
- 3 queries per second
- 100 concurrent queries maximum
429 Too Many Requests error.Best Practices
Use compression
Use compression
Always request gzip compression for large exports:
headers = {'Accept-Encoding': 'gzip'}
Export in reasonable date ranges
Export in reasonable date ranges
Split large exports into smaller chunks:
from datetime import datetime, timedelta
start = datetime(2024, 1, 1)
end = datetime(2024, 12, 31)
# Export one month at a time
current = start
while current < end:
next_date = min(current + timedelta(days=30), end)
export_data(current, next_date)
current = next_date
Use Data Pipelines for regular exports
Use Data Pipelines for regular exports
For scheduled exports, use Data Pipelines instead of polling the Export API.
Event Export
curl --request GET \
--url https://data.mixpanel.com/api/2.0/exportimport requests
url = "https://data.mixpanel.com/api/2.0/export"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://data.mixpanel.com/api/2.0/export', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://data.mixpanel.com/api/2.0/export",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://data.mixpanel.com/api/2.0/export"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://data.mixpanel.com/api/2.0/export")
.asString();require 'uri'
require 'net/http'
url = URI("https://data.mixpanel.com/api/2.0/export")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body