REST API - Referral Endpoints

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

  1. referrals – Retrieves response objects for all referrals on the current site
  2. 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:

http://example.com/wp-json/affwp/v1/referrals
http://example.com/wp-json/affwp/v1/referrals/ID

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

http://example.com/wp-json/affwp/v1/

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

Responses are returned in JSON form.

Example referrals response:

  {
    "referral_id": 21,
    "affiliate_id": 0,
    "visit_id": 0,
    "description": "",
    "status": "",
    "amount": "",
    "currency": "",
    "custom": "",
    "context": "",
    "campaign": "",
    "reference": "",
    "products": "",
    "date": "2016-08-17 19:57:30",
    "payout_id": "102",
    "id": 21
  },
  {
    "referral_id": 22,
    "affiliate_id": 2736,
    "visit_id": 0,
    "description": "",
    "status": "paid",
    "amount": "1.00",
    "currency": "USD",
    "custom": "",
    "context": "",
    "campaign": "",
    "reference": "",
    "products": "",
    "date": "2016-08-17 19:57:43",
    "payout_id": "81",
    "id": 22
  },

Example referrals/{ID} response:

{
  "referral_id": 21,
  "affiliate_id": 0,
  "visit_id": 0,
  "description": "",
  "status": "",
  "amount": "",
  "currency": "",
  "custom": "",
  "context": "",
  "campaign": "",
  "reference": "",
  "products": "",
  "date": "2016-08-17 19:57:30",
  "payout_id": "102",
  "id": 21
}

.