This notebook show how to make call to the AppNexus API.
Implemented functions:
def get_campaign(self, ids=None, one_id=None, advertiser_id=None, only_names=True):
""" cf https://wiki.appnexus.com/display/api/Campaign+Service"""
def get_pixel(self, ids=None, one_id=None, advertiser_id=None,
advertiser_code=None, pixel_code=None, only_names=True):
""" cf https://wiki.appnexus.com/display/api/Conversion+Pixel+Service """
def get_device(self, one_id=None, device_type=None, only_names=True):
""" cf https://wiki.appnexus.com/display/api/Device+Model+Service """
def get_advertiser(self, ids=None, one_id=None, search_term=None, only_names=True):
""" cf https://wiki.appnexus.com/display/api/Advertiser+Service"""
def get_line_item(self, ids=None, one_id=None, advertiser_id=None, only_names=True):
""" cf https://wiki.appnexus.com/display/api/Line+Item+Service"""
def get_insertion_order(self, ids=None, one_id=None, advertiser_id=None, search_term=None, only_names=True):
""" cf https://wiki.appnexus.com/display/api/Insertion+Order+Service"""
def get_segment(self, ids=None, one_id=None, search_term=None, only_names=True):
""" cf https://wiki.appnexus.com/display/api/Segment+Service"""
In [1]:
from pynexus import AppNexusAPI
APPNEXUS_ACCOUNT = {
"username": "",
"password": ""
}
api = AppNexusAPI(**APPNEXUS_ACCOUNT)
Only the mapping id -> name
In [2]:
api.get_device(one_id=80)
Out[2]:
Full response
In [3]:
api.get_device(one_id=80, only_names=False)
Out[3]:
In [5]:
pixels = AppNexusAPI.bulk_requests(api.get_pixel, range(0, 300))
You may also want to retrieve all the elements, without specifying an id.
base the default get function will only return up to 100 elements, you can use the bulk_request_get_all
to avoid hitting the limit.
In [6]:
# We limit here the number of calls to 10
names = AppNexusAPI.bulk_request_get_all(api.get_pixel, limit=10, only_names=True)
In [7]:
print('%d elements downloaded' % len(names))
In [ ]: