Python Quickstart

Welcome to mParticle! Let’s send your first event.

Step 1: Generate your API key

Create a Custom Feed on the Setup page to generate server-to-server API credentials.

Step 2: Install the Python SDK

Install the Python SDK via pip:

pip install git+https://github.com/mparticle/mparticle-python-sdk.git

Step 3: Call the Events API

Integrate mParticle in your Python application.

import mparticle
from mparticle import AppEvent, SessionStartEvent, SessionEndEvent, Batch

batch = Batch()
batch.environment = 'development'

app_event = AppEvent('Hello World', 'navigation')
batch.events = [SessionStartEvent(), app_event, SessionEndEvent()]

configuration = mparticle.Configuration()
configuration.api_key = 'YOUR_API_KEY'
configuration.api_secret = 'YOUR_API_SECRET'

api_instance = mparticle.EventsApi(configuration)
api_instance.upload_events(batch)

Step 4: Verify installation

Go to the Live Stream and watch new events come in as you run your script.

Next Steps

πŸŽ‰πŸŽ‰πŸŽ‰ Congrats on sending your first event to mParticle!

Some ideas on what to do next:

Was this page helpful?