Learn how to integrate LinksTest into your applications
https://api2.linkstest.com/api/createTest
POST
Parameter | Type | Description | Required |
---|---|---|---|
url | string | URL of the test | Yes |
country | string | 2 letter ISO country code | Yes |
device | string | "Android", "iOS", "Mac", "Windows" | Yes |
{
"test": {
"url": "http://example.com/test",
"country": "us",
"device": "Android"
}
}
{
"initialUrl": "https://example.com/initial",
"redirects": [
{
"type": "HTTP",
"url": "https://example.com/redirect1",
"domain": "example.com"
}
],
"hops": 5
}
$url = 'https://api2.linkstest.com/api/createTest';
$apiKey = 'your_api_key_here'; // Replace with actual API key
$data = [
'test' => [
'url' => 'http://example.com/test',
'country' => 'us',
'device' => 'Android'
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Api-Key: ' . $apiKey
]);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
echo $response;
import requests
import json
url = 'https://api2.linkstest.com/api/createTest'
api_key = 'your_api_key_here' # Replace with actual API key
data = {
'test': {
'url': 'http://example.com/test',
'country': 'us',
'device': 'Android'
}
}
headers = {
'Content-Type': 'application/json',
'Api-Key': api_key
}
try:
response = requests.post(url, json=data, headers=headers)
response.raise_for_status()
result = response.json()
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f'Error: {e}')
const fetch = require('node-fetch');
const url = 'https://api2.linkstest.com/api/createTest';
const apiKey = 'your_api_key_here'; // Replace with actual API key
const data = {
test: {
url: 'http://example.com/test',
country: 'us',
device: 'Android'
}
};
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Api-Key': apiKey
},
body: JSON.stringify(data)
};
fetch(url, options)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(result => {
console.log(JSON.stringify(result, null, 2));
})
.catch(error => {
console.error('Error:', error);
});
💡 Tip: Remember to replace 'your_api_key_here' with your actual API key from your LinksTest account settings.
Error | Status | Description |
---|---|---|
Invalid or missing API Key | 401 | Authentication failed |
Insufficient credits | 401 | You do not have enough credits to perform this request |
Invalid data format | 400 | Invalid or poorly formatted data |
Missing test object | 400 | 'test' is required and must be an array |
Missing required fields | 400 | Every test must contain 'url', 'country', and 'device' |
Invalid URL | 400 | The provided URL is not valid |
Invalid country | 400 | Country is not valid |
Invalid device | 400 | Device is not valid |
Method not allowed | 405 | Invalid HTTP method used |
Endpoint not found | 404 | The requested endpoint does not exist |