Important: Please only attempt to use the API with the support of a developer, who will help you avoid causing issues with your site due to custom code.
Available endpoints:
POST /v1/content/publish
You can trigger a site scan and link import using the
/v1/content/publish
endpoint.
As long as you have auto-import enabled, this will cause our system to crawl your newly published post for links and import them immediately for tracking.
Sample request
You'll tell the API which new post or page to crawl for affiliate links.
curl \ -X POST -H "Authorization: Bearer YOUR_SECRET_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "url": "https://yourwebsite.com/newpost" }' \ https://api.affilimate.com/v1/content/publish
Sample integration with WordPress
If you wanted to trigger a link import on every post update, here's how that could work.
function am_trigger_link_import($post_ID, $post, $update) { // Present because Gutenberg fires this hook twice, due to // backwards compatibility with the meta box loader if (!empty( $_REQUEST['meta-box-loader'])) { return; } $apiToken = 'YOUR_API_TOKEN_HERE'; $url = 'https://api.affilimate.com/v1/content/publish'; $body = [ 'url' => get_permalink($post->ID) ]; $headers = array( 'Authorization:Bearer ' . $apiToken, 'Content-Type:application/json' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); } add_action('wp_insert_post', 'am_trigger_link_import', 10, 3);
Available parameters
You can provide the following parameters:
url
- Provide the full URL of the newly published or updated page/post on a website that is currently verified and active in your account.
Sample response
You'll get a 200 status code and a URL of the scan where you can watch the progress of the scan and import.
{ "scanUrl": "https://app.affilimate.com/scan/details/SCAN_DETAIL_URL" }
Potential error states
Errors will return a JSON response including an error code as the field error and optionally a more detailed message under details, for example:
{ "error": "WRONG_METHOD", details: "Use POST method to make this request" }
Potential error codes include:
- 401 NOT_AUTHORIZED – You did not provide a valid API token or provided it incorrectly.
- 400 WRONG_METHOD – You tried to use a method for this endpoint other than POST.
- 400 WRONG_CONTENT_TYPE – You failed to specify the Content-Type header as application/json.
- 400 NO_URL_GIVEN – You forgot to provide, or provided incorrectly, a request body containing a valid URL.
- 500 API_ERROR – A unknown error occurred while processing your request.