PHPackages                             swco/appnexusapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. swco/appnexusapi

ActiveLibrary[API Development](/categories/api)

swco/appnexusapi
================

Interface for accessing the AppNexus read-only API

v1.4.2(10y ago)2374MITPHPPHP &gt;=5.3

Since Jun 6Pushed 9y ago4 watchersCompare

[ Source](https://github.com/swco/appnexusapi)[ Packagist](https://packagist.org/packages/swco/appnexusapi)[ RSS](/packages/swco-appnexusapi/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

AppNexus Read-Only API
======================

[](#appnexus-read-only-api)

[![Latest Stable Version](https://camo.githubusercontent.com/57f63b9cd70d0ddd1356cf4878ad44b08292bd46a0a5e74d0de7d02caa9928ed/68747470733a2f2f706f7365722e707567782e6f72672f7377636f2f6170706e657875736170692f762f737461626c652e737667)](https://packagist.org/packages/swco/appnexusapi) [![Build Status](https://camo.githubusercontent.com/ed3bb3291763a35f3a24c1dca747318fd1082721920442a1fdea5c0be5991e6a/68747470733a2f2f7472617669732d63692e6f72672f7377636f2f6170706e657875736170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/swco/appnexusapi) [![License](https://camo.githubusercontent.com/195d65f81c2d1e3a82bd6c08d17e4403f24b5adc7bc40c530d26c0c23bf46b2b/68747470733a2f2f706f7365722e707567782e6f72672f7377636f2f6170706e657875736170692f6c6963656e73652e737667)](https://packagist.org/packages/swco/appnexusapi)

Installation
------------

[](#installation)

This library requires PHP 5.3 or later, and is installable and autoloadable via Composer as [swco/appnexusapi](https://packagist.org/packages/swco/appnexusapi).

Getting Started
---------------

[](#getting-started)

The examples below show a few different ways you can access data.

When accessing data through the helper `get*` methods the request is sent straight away and returns an array of objects.

When using the `get($service, $reset = true)` method you can continue to apply filtering before calling `send()`. With `send()` you also get the `Response` object returned rather than a regular array. This gives access to a few more methods like `getStatus()` and `getStartElement()`.

The second param passed to `get()` allows you to reset all the filters (default action). Passing `false` will stop `reset()` being called.

```
use \SWCO\AppNexusAPI\Request;

$request = new Request("username", "password");

// Get category ID 1 and 7
$categories = $request->whereId(array(1, 7))->getCategories();

// Get category ID 5
$category = $request->getCategory(5);

// Get all brands update since June 2014
$brands = $request->get(Request::SERVICE_BRAND)->since(new DateTime('June 2014'))->send();
echo $brands->getStatus();// OK

// Domain Audit Statuses are a bit different as they needs some post data
$domainAuditStatus = $request->getDomainAuditStatuses(array('google.com'));
```

All services' parameters default to their falsey value;

```
string = '';
int = 0;
bool = false;
array = array();
float = 0.0;

```

The only exception to this rule is params that should be an object, if unset these will return null;

```
object = null;

```

Advanced
--------

[](#advanced)

Some services (currently Brand) have their own special filter, this is accompanied with a Request wrapper;

```
use \SWCO\AppNexusAPI\Request;
use \SWCO\AppNexusAPI\BrandRequest;

$request = new Request("username", "password");

$brand = BrandRequest::newFromRequest($request);

$brand->simple();

...
```

This allows for extra functionality such as access to the `simple()` method above that removes the `num_creatives` data making the API call a lot faster.

You can also send the simple flags through the helper functions `getBrand()` and `getBrands()`;

```
use \SWCO\AppNexusAPI\Request;
use \SWCO\AppNexusAPI\BrandRequest;

$request = new Request("username", "password");

$brand = BrandRequest::newFromRequest($request);

$simple = true;
$brand->getBrand(1, $simple);
```

Auth
----

[](#auth)

For heavier usage it is worth storing the token for re-use\*. The token doesn't change and the library handles re-authing when needed.

\*The token does change occasionally. If an old token is stored in the config the request will re-auth getting a correct token. There is currently no way of reporting this.

Auth can be handled via the request object or using the `Auth` object directly;

```
use \SWCO\AppNexusAPI\Request;

$request = new Request("username", "password");
$token = $request->auth();

// Store $token somewhere
```

```
use \SWCO\AppNexusAPI\Auth;
use \Guzzle\Http\Client;
use \SWCO\AppNexusAPI\Request;
use \SWCO\AppNexusAPI\Exceptions\NoAuthException;

$auth = new Auth();
$auth->setClient(new Client(Request::APP_NEXUS_API_URL));
try {
    $token = $auth->auth('username', 'password');
} catch (NoAuthException $e) {
    $token = null;
}

if ($token) {
    // Store $token somewhere
}
```

DataPool
--------

[](#datapool)

Generally the API is limited to 100 results per request. There is a `DataPool` object available to get all or a specific number of results by making multiple requests;

```
use SWCO\AppNexusAPI\DataPool;
use SWCO\AppNexusAPI\Request;

$request = new Request('username', 'password');
$request->get(Request::SERVICE_DEVICE_MAKE);

$dataPool = new DataPool();

$data = $dataPool->getAll($request); // Gets all Device Make items

$data = $dataPool->get($request, 250); // Gets the first 250 results of the Device Make items.

$request->offsetBy(250);

$data = $dataPool->get($request, 250); // Gets items 250 - 500.
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~42 days

Recently: every ~2 days

Total

13

Last Release

3856d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce212146c9cc8885135dd6033170f98469a760562184a02345cd632fba1da78b?d=identicon)[garoevans](/maintainers/garoevans)

---

Top Contributors

[![garoevans](https://avatars.githubusercontent.com/u/1016708?v=4)](https://github.com/garoevans "garoevans (67 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/swco-appnexusapi/health.svg)

```
[![Health](https://phpackages.com/badges/swco-appnexusapi/health.svg)](https://phpackages.com/packages/swco-appnexusapi)
```

###  Alternatives

[rackspace/php-opencloud

PHP SDK for Rackspace/OpenStack APIs

4495.9M38](/packages/rackspace-php-opencloud)[cdaguerre/php-trello-api

Trello API v2 client

255666.7k3](/packages/cdaguerre-php-trello-api)[dchesterton/marketo-rest-api

A PHP client for the Marketo.com REST API

41844.1k1](/packages/dchesterton-marketo-rest-api)[carlosio/geckoboard

A PHP library for dealing with Geckoboard API (http://www.geckoboard.com)

40172.2k](/packages/carlosio-geckoboard)[teepluss/api

Laravel 4 Internal Request (HMVC)

7034.0k](/packages/teepluss-api)[jlinn/mandrill-api-php

A PHP client library for Mandrill's REST API

24117.4k](/packages/jlinn-mandrill-api-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
