Basic Authorization

Adscend Offers API Parameters

Your publisher ID pubID, and API Key api_key values are needed for every API call.
These values can be found at Offers API section of the publisher dashboard.


If you would like us to notify you whenever an offer is completed (lead generated), set up a server postback.

Basic Authorization

Authentication for all of our Offers API calls is handled by the "basic authorization" header. This means that to successfully make a call to our API you will need to pass in your publisher ID as the basic authorization username and you API Key as the password. Below we’ve provided several example of how to do this.


You may get your publisher ID and API key from the published dashboard here


Testing API Calls

Basic Authorization allows you to easily test API calls in your browser: open the URL of the API call you want to test in your browser, then provide your Publisher ID for the username and API Key for the password when prompted, the API response will then be shown.


Setting Basic Authorization Headers in Popular Languages

PHP:
$host = "https://api.adscendmedia.com/v1/publisher/{Publisher ID}/offers.json";
$username = "{Publisher ID}";
$password = "{API Key}";
$process = curl_init($host);
curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($process);
curl_close($process);
Java:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;


public class HttpBasicAuth {

    public static void main(String[] args) {

        try {
            URL url = new URL ("https://api.adscendmedia.com/v1/publisher/{Publisher ID}/offers.json");
            String encoding = Base64Encoder.encode ("{Publisher ID}:{API Key}");

            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setDoOutput(true);
            connection.setRequestProperty  ("Authorization", "Basic " + encoding);
            InputStream content = (InputStream)connection.getInputStream();
            BufferedReader in   =
                new BufferedReader (new InputStreamReader (content));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

}
Curl:
 curl --user '{Publisher ID}:{API Key}' https://api.adscendmedia.com/v1/publisher/{Publisher ID}/offers.json
NodeJS:
var request = require('request');

var publisher_id = '{Publisher ID}';
var api_key = '{API Key}';

request({
  url: 'https://api.adscendmedia.com/v1/publisher/{Publisher ID}/offers.json',
  auth: {
    'user': publisher_id,
    'pass': api_key
  }
}, function(err, response, body) {
  console.log(body);
});

Python:
from requests import get
publisher_id = '{Publisher ID}'
api_key = '{API Key}'

response = get('https://api.adscendmedia.com/v1/publisher/{Publisher ID}/offers.json', auth=(publisher_id, api_key))
print response.json()