-
Notifications
You must be signed in to change notification settings - Fork 13
API Client
Sam Dozor edited this page May 27, 2016
·
3 revisions
The SDK provides an interface to the mParticle HTTP API by way of the EventsApi class.
At minimum, the EventsApi
must be initialized with an mParticle key and secret. You can find your mParticle key and secret by navigating to the Apps section of the mParticle platform UI.
You must associate your data with the correct key and secret. If your app is multi-platform, for example, be sure to send your Android data to your Android key/secret, and your iOS data to your iOS key/secret.
configuration = mparticle.Configuration()
configuration.api_key = 'REPLACE WITH APP KEY'
configuration.api_secret = 'REPLACE WITH APP SECRET'
configuration.debug = True #enable logging of HTTP traffic
api_instance = mparticle.EventsApi(configuration)
The EventsAPI class exposes two interfaces:
-
bulk_upload_events
- Accepts up to 100Batch
objects for up to 100 users. -
upload_events
- Accepts a singleBatch
object for a single user
try:
api_instance.upload_events(batch)
# you can also send multiple batches at a time to decrease the amount of network calls
#api_instance.bulk_upload_events([batch, batch])
except mparticle.rest.ApiException as e:
print "Exception while calling mParticle: %s\n" % e