Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The budget API allows publishers to discover what advertisers have budget available at a particular moment in time by making accessible a report, generated on demand of the advertisers and budgets available.

...

HTTP Endpoint

The following endpoint is used with HTTPS HTTP GET:

...

Code Block
xml
xml
<ads>
	<ad>
		<listing_ids> 			<listing_id>1000004</listing_id> 		</listing_ids> 		<reference_id>11</reference_id>
		<net_ppe>0.55</net_ppe>
		<budget_remaining>100000.0</budget_remaining>
		<budget_allocation_id>267382</budget_allocation_id>
	 <ppe>0.2</ppe>
    <remaining_budget>3.0311</remaining_budget>
    <budget_allocation_id>16369425</budget_allocation_id>
    <listings>
      <listing> 
        <listing_id>838628150</listing_id>
        <listing_name>Mojo's Seafood &amp; Chicken</listing_name>
        <reference_id>7</reference_id>
        <categories>
          <category>Catering</category>
          <category>Health Food</category>
          <category>Home Meal Delivery</category>
          <category>Restaurants</category>
          <category primary="true">Seafood Markets</category>
        </categories>
        <markets/>
        <neighborhoods/>
        <postal_codes>
          <postal_code>36542</postal_code>
        </postal_codes>
        <cities>
          <city>Gulf Shores</city>
        </cities>
      </listing>
    </listings>
  </ad>
</ads>

Connecting to the streaming Discovery API

Accessing this API requires keeping a persistent HTTPS connection HTTP connection open. This involves thinking about your client application differently than if you are using a REST API. In other words, use this API as a separate process independent of user requests.

...

To connect to the Discovery API, form an HTTPS HTTP request and download the response file. You must keep the connection open while you are downloading the file. This may be different for every language or framework.

...

Code Block
langhtml
Client: (Using HttpClient, Framework independent)

String endpoint = " httpshttp://stream.api.citygridmedia.com/ads/budget/v2/discover?publisher=test&format=xml";
HttpGet httpGet = new HttpGet(endpoint);
HttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
HttpResponse getResponse = client.execute(httpGet, context);
if (getResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
  int size = -1;
  OutputStream os = new FileOutputStream("result.xml");
  InputStream is = getResponse.getEntity().getContent();
  byte[] buffer = new byte[4096];
  while ((size = is.read(buffer)) != -1) {
    os.write(buffer, 0, size);
  }
  os.flush();
  os.close();
  client.getConnectionManager().shutdown();
}

...

Obtaining Budget Available by Named Geographic Region

HTTPS Endpoint

The following endpoint is used with HTTPS GET:

Request Parameter

The following query string parameters are used with the Budget API endpoint:

...

Obtaining Budget Available by Latitude and Longitude

HTTPS Endpoint

The following endpoint is used with HTTPS GET:

Request Parameter

The following query string parameters are used with the Budget API endpoint:

...

Obtaining Budget Available by ID

HTTPS Endpoint

The following endpoint is used with HTTPS POST or GET:

Request Parameter

The following query string parameters are used with the Budget API endpoint:

...

...