I'll provide you with a full example of using the Raw Event Export API in Python based on the knowledge sources.
Using the Mixpanel Utils Module
The recommended approach is to use the mixpanel-utils Python module, which provides a convenient wrapper around the Raw Export API: LBKSfrom mixpanel_utils import MixpanelUtilsLBKS# Initialize the MixpanelUtils instance mputils = MixpanelUtils( 'ServiceAccountSecretHere', token='ProjectTokenHere', service_account_username='my-user.12345.mp-service-account', project_id=1695321, )LBKS# Export events to a file mputils.export_events( 'event_export.txt', { 'from_date': '2016-01-01', 'to_date': '2016-01-01', 'event': '["App Install"]' } )LBKS
More Advanced Example with Export and Import
Here's a more comprehensive example from the hot shard limits documentation that exports, transforms, and re-imports events: ```import glob import gzip import json from mixpanel_utils import MixpanelUtils
SETTINGS = { "PROJECT_ID": "<REPLACE YOUR PROJECT ID> ", "TOKEN": "<REPLACE PROJECT TOKEN> ", "SA_USERNAME": "<REPLACE SERVICE ACCOUNT USERNAME> ", "SA_PASSWORD": "<REPLACE SERVICE ACCOUNT PASSWORD> ", "EU": False, # set to TRUE if your project is in the EU "EXPORT_FOLDER": "exported_files", # make sure to create the folder if it does not exist "FROM": "2023-09-01", "TO": "2023-09-15", }mputils = MixpanelUtils( SETTINGS["SA_PASSWORD"], token=SETTINGS["TOKEN"], service_account_username=SETTINGS["SA_USERNAME"], eu=SETTINGS["EU"], project_id=SETTINGS["PROJECT_ID"] )
def flush_events(events): global mputils if(len(events) == 0): return False mputils.import_events(events, timezone_offset=0) return True
def transform_event(event): try: data = json.loads(event) data["event"] = data["properties"]["mp_original_event_name"] del data["properties"]["mp_original_event_name"] del data["properties"]["mp_original_distinct_id"] return data except: return False# Export hotshard events mputils.export_events( f'{SETTINGS["EXPORT_FOLDER"]}/events.json', { "from_date": SETTINGS["FROM"], "to_date": SETTINGS["TO"], "event": '["$hotshard_events"]' }, add_gzip_header=True, request_per_day=True, raw_stream=True )
exported_files = glob.glob(f'{SETTINGS["EXPORT_FOLDER"]}/*.json.gz') for file_name in exported_files: events = [] event_queue_max = 50_000 with gzip.open(file_name, 'rt') as file: for line in file: event = transform_event(line) if(event == False): continue events.append(event) if(len(events) > = event_queue_max): flush_events(events) events = []
# Flush remaining events
if(len(events) > 0):
flush_events(events)
events = []LBKS```
Using Direct API Calls
If you prefer to use the Raw Event Export API directly with curl or HTTP requests: LBKScurl --request GET \ --url '[https://data.mixpanel.com/api/2.0/export?from_date=2024-07-23&to_date=2024-07-24&limit=100&event=sample_event](https://data.mixpanel.com/api/2.0/export?from_date=2024-07-23&to_date=2024-07-24&limit=100&event=sample_event)' \ --header 'accept: text/plain' \ --header 'authorization: Basic YOUR_TOKEN'LBKSImportant Notes:
- The Raw Export API has a rate limit of 60 queries per hour, 3 queries per second, and a maximum of 100 concurrent queries
- For EU projects, use residency='eu' when initializing MixpanelUtils
- The exported data is in JSONL format (one JSON object per line)
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Hi Sava M., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
Based on the knowledge sources, Lookup Tables in Mixpanel are designed to enrich event or user profile properties with additional metadata by joining on a shared key (such as your common_id). However, Lookup Tables do not allow you to dynamically transfer or "carry" a property value from one event to another if that property was not present on the original event at the time it was ingested.Lookup Tables work by mapping additional attributes to an existing property value (the join key) across all events where that property exists. For example, if both Event A and Event B have a property common_id, and you upload a Lookup Table that maps common_id to some metadata, both events can be enriched with that metadata. But if the property you need only exists on Event B and not in your Lookup Table, Mixpanel cannot use the Lookup Table to "pull" that property onto Event A retroactively Lookup Tables: Enrich ingested data using a CSV.In summary: - Lookup Tables can enrich events with static metadata based on a shared key. - They cannot be used to transfer dynamic property values from one event to another if those values are not present in the Lookup Table itself.If you need to carry a property from Event B to Event A, neither Lookup Tables nor Borrowed Properties can accomplish this in Mixpanel as of now.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Let me check the knowledge base for you again. One moment! 📚
Mixpanel’s Borrowed Properties feature allows you to “borrow” a property from a prior event and apply it to a later event, but not the other way around. Specifically, you can only carry a property from an earlier event (like Event A) to a later event (like Event B) within a 7-day lookback window. The property is borrowed from the most recent prior event where it is set. There is no functionality in Mixpanel to retroactively carry a property from a later event (Event B) back to an earlier event (Event A), even if both share a unique ID such as common_id Borrowed Properties.So, in your scenario, you cannot use Borrowed Properties to bring a property from Event B (which happens later) to Event A (which happens earlier). The borrowing mechanism only works forward in time, not backward.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Let me check the knowledge base for you again. One moment! 📚
I'm sorry, but the knowledge sources do not mention the ability to create a lookup table in Mixpanel without uploading any data. All documentation and examples specify that a lookup table requires at least a CSV file with a join key column and one or more property columns to be uploaded during creation. There is no reference to creating an empty lookup table or a lookup table without data in the provided sources Lookup Tables: Enrich ingested data using a CSV.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Hi Jorge C., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
I'm sorry, but the knowledge sources do not contain specific information or instructions on how to visualize Mixpanel data directly in Looker Studio (formerly Google Data Studio). The available documentation discusses using Mixpanel for business analytics, exporting data via APIs, and embedding Mixpanel reports in third-party tools like Figma, Coda, Jira, and others, but does not mention Looker Studio as a supported integration or provide steps for connecting the two platforms.If you need to export Mixpanel data, you can use the Export API, Data Pipelines, or CSV exports, and then potentially import that data into Looker Studio via a supported data source. However, the exact process for integrating with Looker Studio is not covered in the provided knowledge sources. For more details on exporting data from Mixpanel, see the Export Methods documentation and Data Pipelines overview.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Hi Simon D., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
