Coder Social home page Coder Social logo

mparticle-python-sdk's Introduction

Python SDK

This is the mParticle Python client SDK - use it to send your data to the mParticle platform and off to 200+ integrations.

Requirements.

Python 2.7 and later.

Installation

python setup.py install

Or install from Github via pip:

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

Import the package:

import mparticle

Manual Installation

If you do not wish to use setuptools, you can download the latest release. Then, to use the bindings, import the package:

import path.to.mparticle

Usage

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 = 'REPLACE WITH API KEY'
configuration.api_secret = 'REPLACE WITH API SECRET'

# Raise the connection pool size if necessary (defaults to 1)
# configuration.connection_pool_size = 50

api_instance = mparticle.EventsApi(configuration)

# synchronous
try: 
    api_instance.upload_events(batch)
    # or api_instance.bulk_upload_events([batch_1, batch_2])
    # both upload and bulk_upload also have _with_http_info signatures,
    # which will return the HTTP status info and headers, along with the body
except mparticle.rest.ApiException as e:
    print "Exception while calling mParticle: %s\n" % e


# asynchronous, specifying your callback function
def my_callback(response):
    if type(response) is mparticle.rest.ApiException:
        print 'An error occured: ' + str(response)
    else:
        #successful uploads will yield an HTTP 202 response and no body
        print response
        
thread = api_instance.upload_events(batch, callback=my_callback)

License

Apache License 2.0

mparticle-python-sdk's People

Contributors

alexs-mparticle avatar devanp92 avatar peterjenkins avatar samdozor avatar tonymillion avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.