REST API - Visit Endpoints

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

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

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

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

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

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

Responses are returned in JSON form.

Example visits response:

  {
    "visit_id": 1,
    "affiliate_id": 5464,
    "referral_id": 0,
    "url": "http://google.com",
    "referrer": "http://affiliatewp.com",
    "campaign": "test",
    "ip": "",
    "date": "2016-09-20 21:58:09",
    "id": 1
  },
  {
    "visit_id": 2,
    "affiliate_id": 5464,
    "referral_id": 0,
    "url": "http://google.com",
    "referrer": "http://affiliatewp.com",
    "campaign": "test",
    "ip": "",
    "date": "2016-09-18 21:58:11",
    "id": 2
  },

Example visits/{ID} response:

{
  "visit_id": 2,
  "affiliate_id": 5464,
  "referral_id": 0,
  "url": "http://google.com",
  "referrer": "http://affiliatewp.com",
  "campaign": "test",
  "ip": "",
  "date": "2016-09-18 21:58:11",
  "id": 2
}

.