GithubHelp home page GithubHelp logo

appnexus's Introduction

Balihoo AppNexus API SDK

The Balihoo AppNexus API SDK provides an easy pythonic interface to interact with the App Nexus API

Installation

The Balihoo AppNexus API SDK is a pip installable package, from git, not (yet) from PyPi:

pip install git+git://github.com/balihoo/appnexus.git

Resource

To start using the API using the SDK, first create an AppNexus Resouce:

    from appnexus.resource import AppNexusResource
    resource = AppNexusResource(config)

The parameter config is a dictionary with configuration options:

config = {
    'username': "my@username",
    'password': "nunyobiz",
    'env': "dev",
    'token_file': "token"
    'memcache_host': "mycache.cache.amazonaws.com",
    'memcache_port': "11211",
}

username and password are credentials you got from AppNexus. env: The environment defines whether or not to use the AppNexus production or test api. Any value other "prod" will use the test api token_file: is the name of a file on disk in which to store auth tokens. This is mostly handy for local testing when your AppNexusResource has a short timespan, and you like to reuse your auth token between instantiations. If this parameter is not in your config, the Resource will re-auth when instantiated. Regardless of this variable, the Resource will reuse a token while instantiated, automatically re-authenticating every hour, or when authorization fails. Both memcache parameters allow you to store a token in memcache. This is convenient for independent, short running / parallel processes, such as AWS Lambda functions

Advertisers

To manage advertisers, the SDK uses Advertiser objects containing all advertiser specific data and functionality. You can use the Resource to create or fetch one or more advertisers,

Creating an Advertiser

adv = resource.create_advertiser("Balihoo API Test", state="inactive")
print(json.dumps(adv.data, indent=4))
adv.data['code'] = 'SomeCode'
advid = adv.save()

The create_advertiser call takes as parameters any of the fields specified in the App Nexus Advertiser API Documentation, Any of these fields can also be accessed after creating the object, through the 'data' dictionary. The save call stores the object remotely

Fetching and updating an advertiser

adv = resource.advertiser_by_id(adv.data['id'])
if not adv is None:
    adv.data['code'] = 'MyCode'
    advid = adv.save()

Deleting an advertiser

adv = resource.advertiser_by_id(adv.data['id'])
if not adv is None:
    adv.delete()

appnexus's People

Contributors

balihoo-gens avatar ghe avatar balihoo-dengstrom avatar balihoo-jflitton avatar

Watchers

 avatar James Cloos avatar  avatar James Hatmaker avatar  avatar  avatar  avatar  avatar  avatar  avatar David Harris avatar Chris Kobayashi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.