This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

appnexus-client is a python wrapper for the Appnexus API

Project Description


General purpose Python client for the AppNexus API.

This library exists because most of the open-source solutions we found were for specific AppNexus tasks, such as reporting. Our solution, however, is meant to be used with any AppNexus service.

As it heavily relies on the AppNexus API, we advise you to read its documentation.

This client uses models in the same way that databases ORM does, but you can also hook it to your own data representations class or simply use Python dictionnaries.

Getting Started


A service is an endpoint on the AppNexus API, representing an entity such as a creative. Here is a complete list of services usable in this client: AccountRecovery, AdProfile, Advertiser, AdQualityRule, AdServer, Brand, Broker, Browser, Campaign, Carrier, Category, City, ContentCategory, Country, Creative, CreativeFormat, Currency, CustomModel, CustomModelParser, Deal, DealBuyerAccess, DealFromPackage, DemographicArea, DeviceMake, DeviceModel, DomainAuditStatus, DomainList, ExternalInvCode, InsertionOrder, InventoryAttribute, InventoryResold, IpRangeService, Label, Language, LineItem, Lookup, NativeCustomKey, ManualOfferRanking, MediaSubtype, MediaType, Member, MobileApp, MobileAppInstance, MobileAppInstanceList, MobileAppStore, MemberProfile, ObjectLimit, OperatingSystem, OperatingSystemExtended, OperatingSystemFamily, OptimizationZone, Package, PackageBuyerAccess, PaymentRule, Pixel, Placement, PlateformMember, Profile, ProfileSummary, Publisher, Region, ReportStatus, Search, Segment, Site, TechnicalAttribute, Template, ThirdpartyPixel, User, UsergroupPattern, VisibilityProfile


You need to be connected to the AppNexus to use it. You should have a username and password to do so.

There is a really simple way to connect to your AppNexus account and start using appnexus-client to get and modify your data. It’s as simple as calling a connect method with your credentials! See by yourself:

from appnexus import connect
connect("my-username", "my-password")

And from here, you can use all the features of the library.


A model in appnexus-client is an abstraction for a service. Most of them are already declared and you just have to import them.

You can access the fields of an AppNexus entity the same way you’d do to access a dict’s values : entity[“field_name”]

You can also iterate through all the cities of AppNexus-API easily. For example, to print the name of each and every city registered in AppNexus, you’d do :

from appnexus import City
for city in City.find():

You can also retrieve a single result (The first one returned by the API) using the find_one method :

city_i_care_about = City.find_one(id=1337)

Filtering and sorting

Sorting with appnexus-client is easy. Just give a sort parameter with a value indicating which field is sorted in which order (asc or desc). This parameter will be supplied to the AppNexus API which will return a sorted response.

You can filter entities using parameters of the methods find and find_one. Each parameter stand as a new filter for the field it is named after. For example, you can search for cities whose country_code field is equal to “FR” and sort them by name:

for city in City.find(country_code="FR", sort="name.desc"):

The parameters you give to the find and find_one methods are translated into query parameters for the requests being send. For example, the snippet Creative.find(state=”active”, advertiser_id=[1, 2, 3]) will result in a get request on,2,3

Please search in the documentation to understand the meaning of each parameter.

Custom Data Representation

You can hook your own data representation class with appnexus-client. For this, you must use a function that exposes this signature:

function(client, service, object)

The client is, of course, an AppNexusClient instance. The service must be a string representing the service to which the object belongs. And finally, the object is a python dictionnary containing data about an AppNexus entity. The return value of this function will be used as a data representation.

To use this function and get the desired data representation, you must pass it to the client through the representation keyword argument.

If you want to retrieve data as a list of tuples instead of a dict, you could do the following:

def tuple_representation(client, service, object):
    return object.items()
connect("username", "password", representation=tuple_representation)
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
appnexus-client-0.3.0.tar.gz (15.0 kB) Copy SHA256 Checksum SHA256 Source Mar 6, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting