All Projects → marmurar → Pyamplitude

marmurar / Pyamplitude

Licence: mit
A Python connector for Amplitude Analytics

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pyamplitude

Countly Server
Countly helps you get insights from your application. Available self-hosted or on private cloud.
Stars: ✭ 4,857 (+30256.25%)
Mutual labels:  tracking, mobile
Countly Sdk Cordova
Countly Product Analytics SDK for Cordova, Icenium and Phonegap
Stars: ✭ 69 (+331.25%)
Mutual labels:  data-analysis, mobile
Ng Zorro Antd Mobile
A configurable Mobile UI components based on Ant Design Mobile and Angular. 🐜
Stars: ✭ 709 (+4331.25%)
Mutual labels:  mobile
Mailtrackerblocker
Email tracker, read receipt and spy pixel blocker plugin for macOS Apple Mail
Stars: ✭ 821 (+5031.25%)
Mutual labels:  tracking
Crboxinputview
Verify code input view. Support security type for password.短信验证码输入框,支持密文模式
Stars: ✭ 749 (+4581.25%)
Mutual labels:  mobile
Hblock
Improve your security and privacy by blocking ads, tracking and malware domains.
Stars: ✭ 724 (+4425%)
Mutual labels:  tracking
Elide
Elide is a Java library that lets you stand up a GraphQL/JSON-API web service with minimal effort.
Stars: ✭ 766 (+4687.5%)
Mutual labels:  mobile
Rotki
A portfolio tracking, analytics, accounting and tax reporting application that protects your privacy
Stars: ✭ 689 (+4206.25%)
Mutual labels:  tracking
Jeelizweboji
JavaScript/WebGL real-time face tracking and expression detection library. Build your own emoticons animated in real time in the browser! SVG and THREE.js integration demos are provided.
Stars: ✭ 835 (+5118.75%)
Mutual labels:  tracking
Getting Started
This repository is a getting started guide to Singer.
Stars: ✭ 734 (+4487.5%)
Mutual labels:  data-analysis
Awesome Python Data Science
Probably the best curated list of data science software in Python.
Stars: ✭ 812 (+4975%)
Mutual labels:  data-analysis
Qr Filetransfer
Transfer files over WiFi between your computer and your smartphone from the terminal
Stars: ✭ 738 (+4512.5%)
Mutual labels:  mobile
Pandas exercises
Practice your pandas skills!
Stars: ✭ 7,140 (+44525%)
Mutual labels:  data-analysis
Trape
People tracker on the Internet: OSINT analysis and research tool by Jose Pino
Stars: ✭ 6,753 (+42106.25%)
Mutual labels:  tracking
Ring
Innovative and practical general-purpose multi-paradigm language
Stars: ✭ 716 (+4375%)
Mutual labels:  mobile
Mobile Select
手机移动端选择组件 支持是否级联/单选到多选/可异步更新数据等..
Stars: ✭ 829 (+5081.25%)
Mutual labels:  mobile
Cookbook 2nd
IPython Cookbook, Second Edition, by Cyrille Rossant, Packt Publishing 2018
Stars: ✭ 704 (+4300%)
Mutual labels:  data-analysis
Embeddinator 4000
Tools to turn .NET libraries into native libraries that can be consumed on Android, iOS, Mac, Linux and other platforms.
Stars: ✭ 735 (+4493.75%)
Mutual labels:  mobile
Statsmodels
Statsmodels: statistical modeling and econometrics in Python
Stars: ✭ 6,935 (+43243.75%)
Mutual labels:  data-analysis
Realm Core
Core database component for the Realm Mobile Database SDKs
Stars: ✭ 836 (+5125%)
Mutual labels:  mobile

alt text

PyAmplitude

...What is Pyamplitude ?

Amplitude its a python-based client designed to interact with the entire set of Amplitude Analytics services (Redshift, Export API, Dashboard Rest API and Behavioral Cohorts API) following the official Amplitude Documentation which can be found at:

https://amplitude.zendesk.com/hc/en-us/categories/115000290488-Technical-Resources

General Organization:

 AmplitudeRestApi   -> A wrapper around each Rest API resources.
 RedshfitAmplitude  -> A sql connector for the Amplitude AWS-Redshift database.
 ExportApi          -> A wrapper around the entire Amplitude export

Aditional Modules:

Resources      -> Api resources ( Manage several apps & secret keys, import Segments to get data using Segment definitions )

Aditional Features:

- Calculate each query cost.
- Manage your query rate limits in a ETL context.
- Visualize the quentity of requests and your query limit status.

Install

pip install pyamplitude

How to use PyAmplitude ?

Let's start by importing the ProjectHandler and passing a project_name, api_key and api_secret key as parameters.

from pyamplitude.projectshandler import ProjectsHandler

Lets instance the ProjectHanlder with our first app called 'BubbleWay'...

bubbleConector = ProjectsHandler(project_name='BubbleWay',
				 api_key='<api_key>',
				 secret_key='<secret_key>')

Hint: Use the repr method to check your actual instance when used with several apps.

print bubbleConector

project_name: BubbleWay | api_key: API-KEY | secret_key: API-SECRET

from pyamplitude.amplituderestapi import AmplitudeRestApi

Querying data from the Amplitude Analytics REST API Dashboard

Great ! So let's use the Amplitude Rest Api to query some useful data for later analysis...

apiconector = AmplitudeRestApi(project_handler = bubbleConector,
                               show_logs       = False,
                               show_query_cost = False)

Creating and using segments

Segments are represented as JSON arrays, where each element is a JSON object corresponding to a filter condition. First import and initialize the Segment class and add each query filter. in these cases we will be creating two segment definitions and for later use.

first_segment_definition = Segment()

first_segment_definition.add_filter(prop='country',op='is',values=['argentina','brasil'])

second_segment_definition = Segment()

second_segment_definition.add_filter(prop='country',op='is',values=['argentina','paraguay'])

Using the AmplitudeRestApi module.

First Example: Querying Active and New Users count
data = apiconector.get_active_and_new_user_count(start    = '20170814',
                                                 end      = '20170825',
                                                 m        = 'active',
                                                 interval = 1,
                                                 segment_definitions = [first_segment_definition,
                                                                        second_segment_definition],
                                                 group_by            = None)
If all goes well... you should receive a JSON response such as:

{
    "data": {
        "series": [
                    [18600,15294,14164,12945,12585,11797,10113,9523,8321,7873,9053,8109],
                    [3264,3423,3397,2984,2916,2827,2918,2934,1800,1560,1240,1100]
        ],
        "seriesMeta": ["Argentina", "Brasil"],
        "xValues": ["2017-08-14", "2017-08-15", "2017-08-16", "2017-08-17", "2017-08-18", "2017-08-19", "2017-08-20",
                    "2017-08-21", "2017-08-22", "2017-08-23", "2017-08-24", "2017-08-25"]
    }
}

Other Resources: Session Length Distribution, Average Session Length, Average Sessions per User, User Composition, Events, Events List, Event Segmentation, Funnel Analysis, Retention Analysis, User Activity, User Search, Real-time Active Users, Revenue Analysis, Revenue LTV, Annotations...

Aditional options

Using calculate_query_cost = True parameter

With PyAmplitude you can calculate each query cost very easily by checking the show_query_cost parameter. In an ETL context you may use this option not to exceed query limits. If you want to know more about how each query cost is being calculated, please read:

https://amplitude.zendesk.com/hc/en-us/articles/205469748-Dashboard-Rest-API-Export-Amplitude-Dashboard-Data#request-limits

Fetching data from Amplitude Redshift

As a addition you can query data from Amplitude Redshift using the AmplitudeReshift module.

from pyamplitude.amplituderestshift import AmplitudeRedshift
ConnectionHandler = AmplitudeRedshift(host='',
                                      user='BubbleUser',
                                      port='5439',
                                      password=<yourpassword>,
                                      dbname='bubble_db',
                                      schema= 'app123098',
                                      table=<db_table>,
                                      show_logs= True)
query = 'SELECT * FROM app123098.bubble_db LIMIT 10'
ConnectionHandler.execute_query(query=query)

NOTE: AmplitudeRedshift has a serious of prebuild methods to fetch a list of users, query user events as well as new users, but you can also pass your specific query using the execute_query method.

Authors

Marcos Manuel Muraro

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].