python interface for the atomx api on https://api.atomx.com
Project description
Python Atomx Api
================
Interface for the atomx rest api.
For more information read the full
`documentation online <http://atomx-api-python.readthedocs.org/en/latest/index.html>`_,
report bugs in `github <https://github.com/atomx/atomx-api-python>`_
or see the `atomx wiki <http://wiki.atomx.com/doku.php?id=api>`_
Example Usage
-------------
.. code-block:: python
from atomx import Atomx
# create atomx session
atomx = Atomx('user@example.com', 'password')
# get 10 creatives
creatives = atomx.get('Creatives', limit=10)
# the result is a list of `atomx.models.Creative` models
# that you can easily inspect, manipulate and update
for creative in creatives:
print('Creative ID: {c.id}, state: {c.state}, '
'name: {c.name}, title: {c.title}'.format(c=creative))
# update title for the first creative in list
creative = creatives[0]
creative.title = 'shiny new title'
# the session is inherited from `atomx` that made the get request
creative.save()
# create a new profile
from atomx.models import Profile
profile = Profile(advertiser_id=23, name='test profile')
# Note that you have to pass it a valid `Atomx` session for create
# or use `atomx.create(profile)`
profile.create(atomx)
# now you could alter and update it like the creative above
profile.name = 'changed name'
profile.save()
# you can also get attributes
profiles = atomx.get('advertiser/88/profiles')
# profiles is now a list of `atomx.models.Profile` that you can
# read, update, etc again.
profiles[0].click_frequency_cap_per = 86400
profiles[0].save()
# working with search
s = atomx.search('mini*')
# s is now a dict with lists of search results for the different models
# with the model id and name
publisher = s['publisher'][0] # get the first publisher..
publisher.reload() # .. and load all the data
print(publisher) # now all publisher data is there
# reporting example
# get a report for a specific publisher
report = atomx.report(scope='publisher', groups=['hour_formatted'], sums=['impressions', 'clicks'], where=[['publisher_id', '==', 42]], from_='2015-02-08 00:00:00', to='2015-02-09 00:00:00', timezone='America/Los_Angeles')
# check if report is ready
print(report.is_ready)
# if pandas is installed you can get the pandas dataframe with `report.pandas`
# you can also get the report csv in `report.content` without pandas
df = report.pandas
# set index to datetime
import pandas as pd
df.index = pd.to_datetime(df.pop('hour_formatted'))
# calculate mean, median, std per hour
means = df.resample('H', how=['mean', 'median', 'std'])
# and plot impression and clicks per day
means['impressions'].plot()
means['clicks'].plot()
Installation
------------
To install the python atomx api, simply:
.. code-block:: bash
$ pip install atomx
or if you want to use ipython notebook and reporting functionality:
.. code-block:: bash
$ pip install atomx[report]
1.2
---
- you can now remove model attributes with `del`
- add :meth:`atomx.models.Report.csv` property that returns the report content as a list
- save logged in user as `user` property to :class:`atomx.Atomx`
- add network reports
- try to determine report scope from user access rights if no scope was specified
1.1
---
- fix: setup.py not working under some environments (`open` used wrong codec)
- add SellerProfile model
- add `offset` parameter to report.get
1.0
---
- First release
================
Interface for the atomx rest api.
For more information read the full
`documentation online <http://atomx-api-python.readthedocs.org/en/latest/index.html>`_,
report bugs in `github <https://github.com/atomx/atomx-api-python>`_
or see the `atomx wiki <http://wiki.atomx.com/doku.php?id=api>`_
Example Usage
-------------
.. code-block:: python
from atomx import Atomx
# create atomx session
atomx = Atomx('user@example.com', 'password')
# get 10 creatives
creatives = atomx.get('Creatives', limit=10)
# the result is a list of `atomx.models.Creative` models
# that you can easily inspect, manipulate and update
for creative in creatives:
print('Creative ID: {c.id}, state: {c.state}, '
'name: {c.name}, title: {c.title}'.format(c=creative))
# update title for the first creative in list
creative = creatives[0]
creative.title = 'shiny new title'
# the session is inherited from `atomx` that made the get request
creative.save()
# create a new profile
from atomx.models import Profile
profile = Profile(advertiser_id=23, name='test profile')
# Note that you have to pass it a valid `Atomx` session for create
# or use `atomx.create(profile)`
profile.create(atomx)
# now you could alter and update it like the creative above
profile.name = 'changed name'
profile.save()
# you can also get attributes
profiles = atomx.get('advertiser/88/profiles')
# profiles is now a list of `atomx.models.Profile` that you can
# read, update, etc again.
profiles[0].click_frequency_cap_per = 86400
profiles[0].save()
# working with search
s = atomx.search('mini*')
# s is now a dict with lists of search results for the different models
# with the model id and name
publisher = s['publisher'][0] # get the first publisher..
publisher.reload() # .. and load all the data
print(publisher) # now all publisher data is there
# reporting example
# get a report for a specific publisher
report = atomx.report(scope='publisher', groups=['hour_formatted'], sums=['impressions', 'clicks'], where=[['publisher_id', '==', 42]], from_='2015-02-08 00:00:00', to='2015-02-09 00:00:00', timezone='America/Los_Angeles')
# check if report is ready
print(report.is_ready)
# if pandas is installed you can get the pandas dataframe with `report.pandas`
# you can also get the report csv in `report.content` without pandas
df = report.pandas
# set index to datetime
import pandas as pd
df.index = pd.to_datetime(df.pop('hour_formatted'))
# calculate mean, median, std per hour
means = df.resample('H', how=['mean', 'median', 'std'])
# and plot impression and clicks per day
means['impressions'].plot()
means['clicks'].plot()
Installation
------------
To install the python atomx api, simply:
.. code-block:: bash
$ pip install atomx
or if you want to use ipython notebook and reporting functionality:
.. code-block:: bash
$ pip install atomx[report]
1.2
---
- you can now remove model attributes with `del`
- add :meth:`atomx.models.Report.csv` property that returns the report content as a list
- save logged in user as `user` property to :class:`atomx.Atomx`
- add network reports
- try to determine report scope from user access rights if no scope was specified
1.1
---
- fix: setup.py not working under some environments (`open` used wrong codec)
- add SellerProfile model
- add `offset` parameter to report.get
1.0
---
- First release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
atomx-1.2.tar.gz
(24.7 kB
view details)
Built Distribution
atomx-1.2-py2.py3-none-any.whl
(14.2 kB
view details)
File details
Details for the file atomx-1.2.tar.gz
.
File metadata
- Download URL: atomx-1.2.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f72d19ba2c88a68a8d066993430e4e993557045bf97c4ed8acdf92807096edd |
|
MD5 | 7df1bb4ce409f28a298c6e5acbe2c2c7 |
|
BLAKE2b-256 | 1d2ea9ba73e5c67dc002ea8fbcd351e58977441cfb8a3f2d6c97417321dd0c91 |
File details
Details for the file atomx-1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: atomx-1.2-py2.py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6293e3e80c73a9c96b33f083c752e2ee8440b5338dfdfb6174071adc0ad2b561 |
|
MD5 | a93fe26e6f4bf70c8329758f3320ca4a |
|
BLAKE2b-256 | e3487ad68421b38cea09e9f893426baf03c261dd595735df76ae2af700991ea4 |