Skip to main content

python interface for the atomx api on https://api.atomx.com

Project description

Interface for the atomx rest api.

For more information read the full documentation online, report bugs in github or see the atomx wiki

Example Usage

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')
# equivalent is to pass the complete resource path as string instead of arguments
profiles = atomx.get('advertiser/88/profiles')  # same as above
# 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
publisher.history()  # gets all changes made to this publisher


# reporting example
# get a report for a specific publisher
report = atomx.report(scope='publisher', groups=['hour'], metrics=['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  # A datetime index is automatically set when group by a hour/day/month.
# 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:

$ pip install atomx

or if you want to use ipython notebook and reporting functionality:

$ pip install atomx[report]

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.6.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

atomx-1.6-py2.py3-none-any.whl (15.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file atomx-1.6.tar.gz.

File metadata

  • Download URL: atomx-1.6.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for atomx-1.6.tar.gz
Algorithm Hash digest
SHA256 9a504540cdaf2b25966e6ec66f420206ed0291b0a54457edb54bb4cfae52443f
MD5 631447a20ec4aa32d41329661e355c3b
BLAKE2b-256 49bd12f072f578ca7a821b1ce7a80c13099b57248511318e8e88990a12305646

See more details on using hashes here.

File details

Details for the file atomx-1.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for atomx-1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 63f107e75f871512273594c0a12f416504e2d6da20fcc3adda7d5f7fb83bb933
MD5 04e7551ffb8a15ff79f32e471301f73e
BLAKE2b-256 c9653c64bf189a654bc8aa84207ba471377b98f7ff8d0007bdbe6d01d31d644a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page