Arabianaffiliates 1.9 introduced a slew of read-only REST endpoints that build upon the infrastructure included with WordPress 4.4 and later.

In order to leverage core REST endpoints, all API consumers must authenticate using API keys generated from a new API Keys tab located at Affiliates → Tools → API Keys.

See the REST API Authentication article for more information on generating and managing API keys.

Routes and Endpoints
Out of the box, Arabianaffiliates 1.9+ offers five routes and multiple underlying endpoints. Those five routes are:

affiliates
creatives
payouts
referrals
visits
Click the route names above to find out more about their respective endpoints, see example requests, and more.

Note: complete Create, Read, Update, and Delete (CRUD) operations can be enabled through the REST API Extended add-on. See the REST API Extended documentation for information on Create, Update, and Delete operations.

 

The REST API uses basic authentication with a combination of a Public Key and Token.

Before you can authenticate an API request, you need a set of API keys. These are user-specific and can be created in Affiliates → Tools → API Keys:

To generate a new set of API keys, enter the username of the user the keys should belong to and click Generate New API Keys.

Note: the user account the API keys are associated with must have the proper capabilities in order for the API to work. Typically this means the user needs to have the Administrator role. See our documentation on roles and capabilities for more information.

Once the API keys are created, you can authenticate with the REST API by including the keys in the authentication header. The Public Key should be passed as the user and the Token as the password.

For example, using Postman, our authenticated request would look like this:

If using curl, an authenticated request would look like this:

 

Arabianaffiliates core 1.9+ offers two, read-only REST endpoints for affiliates:

affiliates – Retrieves response objects for all affiliates on the current site
affiliates/{ID} – Retrieves a response object for an affiliate with the given affiliate ID
The affiliate endpoints can be accessed via GET requests at the following locations:

All affiliate endpoints and their various options are also discoverable by visiting the Arabianaffiliates REST namespace directly:

Endpoints

The affiliates endpoint accepts any valid get_affiliates() arguments:

number – The number of results to retrieve (if available)
offset – The number of results to offset in the query. Default is 0 (no offset)
affiliate_id – The affiliate ID or array of IDs to query for.
user_id – The user ID or array of IDs to query payouts for.
exclude – Affiliate ID or array of IDs to exclude from the request.
search – Terms to search for affiliates. Accepts an affiliate ID or a string.
status – The affiliate status. Accepts ‘active’, ‘inactive’, ‘pending’, or ‘rejected’.
order – How to order results. Accepts ‘ASC’ (ascending) or ‘DESC’ (descending).
orderby – Which field to order the response results by. Default is ‘date’
fields – Specific fields to return for each affiliate in the response. Default ‘*’ (all). Accepts ‘ids’ or any valid column

 

Additional arguments:

user – If user is passed as true, custom user objects will be retrieved on the fly for each affiliate in the response. Care should be taken when using this option due to the 1:1 increase in database queries associated with each affiliate
meta – If passed as true, an array of affiliate meta will be retrieved on the fly for each affiliate in the response. Just as with user, care should be taken due to the decreased performance impact.
All valid arguments can also be derived by sending an OPTIONS request to the either endpoint.

The affiliates/{ID} endpoint accepts any valid affiliate ID. Additionally, if user and/or meta are passed as true, a custom user object and/or array of affiliate meta will respectively be retrieved on the fly to include with the response.

Visibility
All endpoints require the API key and token except for the main affwp/v1 endpoint.

Response
Responses are returned in JSON form.

Arabianaffiliates core 1.9+ offers two, read-only REST endpoints for creatives:

creatives – Retrieves response objects for all creatives on the current site
creatives/{ID} – Retrieves a response object for an creative with the given creative ID
The creative endpoints can be accessed via GET requests at the following locations:

Endpoints

The creatives endpoint accepts any valid get_creatives() arguments:

number – The number of results to retrieve (if available)
offset – The number of results to offset in the query. Default is 0 (no offset)
creative_id – The creative ID or array of IDs to query for.
status – The creative status. Accepts ‘active’ or ‘inactive’.
order – How to order results. Accepts ‘ASC’ (ascending) or ‘DESC’ (descending).
orderby – Creatives table column to order by.
fields – Specific fields to return for each creative in the response. Default ‘*’ (all). Accepts ‘ids’ or any valid column.
All valid arguments can also be derived by sending an OPTIONS request to the either endpoint.

The creatives/{ID} endpoint accepts any valid creative ID.

Visibility
All endpoints require the API key and token except for the main affwp/v1 endpoint.

Response
Responses are returned in JSON form.

Arabianaffiliates core 1.9+ offers two, read-only REST endpoints for payouts:

payouts – Retrieves response objects for all payouts on the current site
payouts/{ID} – Retrieves a response object for an payout with the given payout ID
The payout endpoints can be accessed via GET requests at the following locations:

Endpoints

The payouts endpoint accepts any valid get_payouts() arguments:

number – The number of results to retrieve (if available)
offset – The number of results to offset in the query. Default is 0 (no offset)
payout_id – The payout ID or array of IDs to query for.
affiliate_id – The affiliate ID or array of IDs to query payouts for.
referrals – Referral ID or array of referral IDs to retrieve payouts for.
amount – Payout amount (float) or min/max range (array) to retrieve payouts for.
amount_compare – Comparison operator used with amount. Accepts ‘>’, ‘<‘, ‘>=’, ‘<=’, ‘=’, or ‘!=’.
status – The payout status. Accepts ‘paid’ or ‘failed’
date – The date array or string to query payouts within.
order – How to order results. Accepts ‘ASC’ (ascending) or ‘DESC’ (descending).
orderby – Which field to order the response results by. Default is ‘date’
fields – Specific fields to return for each payout in the response. Default ‘*’ (all). Accepts ‘ids’ or any valid column
All valid arguments can also be derived by sending an OPTIONS request to the either endpoint.

The payouts/{ID} endpoint accepts any valid payout ID.

Visibility
All endpoints require the API key and token except for the main affwp/v1 endpoint.

Response

 

Arabianaffiliates core 1.9+ offers two, read-only REST endpoints for referrals:

referrals – Retrieves response objects for all referrals on the current site
referrals/{ID} – Retrieves a response object for an referral with the given referral ID
The referral endpoints can be accessed via GET requests at the following locations:

Endpoints

The referrals endpoint accepts any valid get_referrals() arguments:

number – The number of results to retrieve (if available)
offset – The number of results to offset in the query. Default is 0 (no offset)
referral_id – The referral ID or array of IDs to query for.
affiliate_id – The affiliate ID or array of IDs to query for.
reference – Reference information (product ID) for the referral.
ref_context – The context under which the referral was created (integration).
campaign – The associated campaign.
status – The referral status or array of statuses. Accepts ‘paid’, ‘unpaid’, ‘pending’, or ‘rejected’.
order – How to order results. Accepts ‘ASC’ (ascending) or ‘DESC’ (descending).
orderby – Which field to order the response results by. Default is ‘date’
search – A referral ID or the search string to query for referrals with.
date – The date array or string to query referrals within.
fields – Specific fields to return for each referral in the response. Default ‘*’ (all). Accepts ‘ids’ or any valid column
All valid arguments can also be derived by sending an OPTIONS request to the either endpoint.

The referrals/{ID} endpoint accepts any valid referral ID.

Visibility
All endpoints require the API key and token except for the main affwp/v1 endpoint.

Response

Arabianaffiliates core 1.9+ offers two, read-only REST endpoints for visits:

visits – Retrieves response objects for all visits on the current site
visits/{ID} – Retrieves a response object for an visit with the given visit ID
The visit endpoints can be accessed via GET requests at the following locations:

Endpoints


The visits endpoint accepts any valid get_visits() arguments:

  • number – The number of results to retrieve (if available)
  • offset – The number of results to offset in the query. Default is 0 (no offset)
  • visit_id – The visit ID or array of IDs to query visits for.
  • affiliate_id – The affiliate ID or array of IDs to query visits for.
  • referral_id – The referral ID or array of IDs to query visits for.
  • referral_status – The referral status or array of statuses to retrieve visits for.
  • campaign – The associated campaign.
  • order – How to order the visit in the response. Default is ‘ASC’ (ascending)
  • orderby – Which field to order the response results by. Default is ‘date’
  • fields – Specific fields to return for each visit in the response. Default ‘*’ (all). Accepts ‘ids’ or any valid column

All valid arguments can also be derived by sending an OPTIONS request to the either endpoint.

The visits/{ID} endpoint accepts any valid visit ID.

Visibility

All endpoints require the API key and token except for the main affwp/v1 endpoint.

Response