Advertiser Integration
API Tracking Integration

Integration Steps

1. Authentication

Linkbest will provide you with a unique ADS_KEY which you can use to call Linkbest's API. You can obtain the ADS_KEY in the brand backend (opens in a new tab).

2. Request Interface Requirements

  • Encoding Requirement: The data sent must be encoded in UTF-8.

  • Request Method: POST

  • HTTP Content-Type Requirement: When encoding the request body as a form, set the HTTP Content-Type header to application/x-www-form-urlencoded. When encoding the request body as JSON, set it to application/json. If you need to upload a file as part of the request, specify multipart/form-data.

  • Linkbest API Endpoint:

    https://api.linkbest.com
  • Request Parameter Format Restrictions:

    Parameter TypeFormat Requirements
    string255 UTF-8 characters
    decimal8 digits, 2 decimal places
    datetimeISO-8601 (e.g., 2022-12-11T11:10:01-07:00)
    currencyISO-4217 (e.g., USD)
    integer16 digits

3. Request Example

Each API route should include the ADS_KEY and the corresponding SERVICE_NAME. You can find the specific SERVICE_NAME for each API in the API documentation.

curl Example
# Example curl command
curl -X POST https://api.linkbest.com/{ADS_KEY}/{SERVICE_NAME} \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -d 'OrderId=TestOrderId'
PHP Request Example
// Example PHP code
<?php
$ch = curl_init();
$data = [
    "OrderID"=>"TestOrderId",
];
curl_setopt($ch, CURLOPT_URL, 'https://api.linkbest.com/{ADS_KEY}/{SERVICE_NAME}');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
$headers = [
    'Content-Type: application/x-www-form-urlencoded',
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 
$server_output = curl_exec($ch);
 
curl_close ($ch);
 
print_r($server_output);
?>
 
Go Request Example
// Example Go code
package main

import (
	"net/http"
	"strings"
	"io/ioutil"
)

func main() {
	url := "https://api.linkbest.com/{ADS_KEY}/{SERVICE_NAME}"
	method := "POST"

	payload := strings.NewReader("OrderId=TestOrderId")

	client := &http.Client {}
	req, err := http.NewRequest(method, url, payload)

	if err != nil {
		fmt.Println(err)
		return
	}
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	res, err := client.Do(req)
	defer res.Body.Close()
	body, err := ioutil.ReadAll(res.Body)

	fmt.Println(string(body))
}
Java Request Example
// Example Java code
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) throws Exception {
        URL url = new URL ("https://api.linkbest.com/{ADS_KEY}/{SERVICE_NAME}");
        String urlParameters = "OrderId=TestOrderId";
        byte[] postData = urlParameters.getBytes( StandardCharsets.UTF_8 );
        int postDataLength = postData.length;
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();           
        conn.setDoOutput(true);
        conn.setInstanceFollowRedirects(false);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
        conn.setRequestProperty("charset", "utf-8");
        conn.setRequestProperty("Content-Length", Integer.toString(postDataLength ));
        conn.setUseCaches(false);
        try(OutputStream wr = conn.getOutputStream()) {
            wr.write(postData);
        }
        int responseCode = conn.getResponseCode();
        System.out.println(responseCode);
    }
}

4. Error Handling

There may be failures when making API requests for various reasons. When an error is returned, the system provides a message indicating more detailed information about the failure. Please adjust accordingly based on this information and retry, or contact our integration engineer for assistance. For more information, please refer to the error codes.