REST API - Creative Endpoints
AffiliateWP 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:
http://example.com/wp-json/affwp/v1/creatives http://example.com/wp-json/affwp/v1/creatives/ID
All creative endpoints and their various options are also discoverable by visiting the AffiliateWP REST namespace directly:
http://example.com/wp-json/affwp/v1/
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.
Example creatives sresponse:
{ "creative_id": 2, "name": "My Other Creative", "description": "", "url": "http://affiliate.dev", "text": "AffiliateWP Plugin Testing", "image": "", "status": "inactive", "date": "2016-05-11 23:35:58", "id": 2 }, { "creative_id": 3, "name": "Special Case", "description": "", "url": "http://affiliate.dev", "text": "AffiliateWP Plugin Testing", "image": "https://affwp.dev/wp-content/images/brand-assets/affiliatewp-1v.png", "status": "active", "date": "2016-05-11 23:43:02", "id": 3 },
Example creatives/{ID} response:
{ "creative_id": 2, "name": "My Other Creative", "description": "", "url": "http://affiliate.dev", "text": "AffiliateWP Plugin Testing", "image": "", "status": "inactive", "date": "2016-05-11 23:35:58", "id": 2 }
.