Create Test (Async)
URL: https://linkstest.com/api/tests
Method: POST
Auth: Api-Key header
⚠️ API Access Required: Your account must be on an API-enabled plan to use this endpoint.
Request Parameters
| Parameter | Type | Description | Required |
| url | string | URL to test | Required |
| country | string | 2-letter ISO country code | Required |
| device | string | "Android", "iOS", "Mac", "Windows" | Required |
| version | string | Optional OS version hint | Optional |
| city | string | Optional city override | Optional |
Request Body
{
"test": {
"url": "http://example.com/test",
"country": "us",
"device": "Android"
}
}
Response — Queued
{
"status": "pending",
"test_id": "uuid",
"credits_remaining": 987
}
Check Test Status
URL: https://linkstest.com/api/tests/{test_id}
Method: GET
Auth: Api-Key header
Status Response — Success
{
"status": "success",
"test_id": "uuid",
"result": {
"result": "success",
"test_id": "uuid",
"data": {
"init": {
"url": "http://example.com/test",
"os": "Android",
"country": "us",
"version": "",
"city": ""
},
"hops": [
{
"from": "https://example.com/initial",
"to": "https://example.com/redirect1",
"status": 302
}
]
}
},
"credits_remaining": 987
}
Code Examples
PHP
$url = 'https://linkstest.com/api/tests';
$apiKey = 'your_api_key_here';
$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);
curl_close($ch);
$result = json_decode($response, true);
echo $response;
// Poll for result
if (!empty($result['test_id'])) {
$statusUrl = 'https://linkstest.com/api/tests/' . $result['test_id'];
for ($i = 0; $i < 10; $i++) {
sleep(2);
$ch = curl_init($statusUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Api-Key: ' . $apiKey]);
echo curl_exec($ch);
curl_close($ch);
}
}
Python
import requests, json, time
url = 'https://linkstest.com/api/tests'
api_key = 'your_api_key_here'
headers = {'Content-Type': 'application/json', 'Api-Key': api_key}
data = {'test': {'url': 'http://example.com/test', 'country': 'us', 'device': 'Android'}}
try:
response = requests.post(url, json=data, headers=headers)
response.raise_for_status()
result = response.json()
print(json.dumps(result, indent=2))
test_id = result.get('test_id')
if test_id:
status_url = f'https://linkstest.com/api/tests/{test_id}'
for _ in range(10):
time.sleep(2)
status_resp = requests.get(status_url, headers={'Api-Key': api_key})
print(status_resp.text)
except requests.exceptions.RequestException as e:
print(f'Error: {e}')
Node.js
const fetch = require('node-fetch');
const url = 'https://linkstest.com/api/tests';
const apiKey = 'your_api_key_here';
const data = { test: { url: 'http://example.com/test', country: 'us', device: 'Android' } };
fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Api-Key': apiKey },
body: JSON.stringify(data)
})
.then(r => r.json())
.then(async result => {
console.log(JSON.stringify(result, null, 2));
if (result.test_id) {
const statusUrl = `https://linkstest.com/api/tests/${result.test_id}`;
for (let i = 0; i < 10; i++) {
await new Promise(r => setTimeout(r, 2000));
const s = await fetch(statusUrl, { headers: { 'Api-Key': apiKey } });
console.log(await s.text());
}
}
})
.catch(err => console.error('Error:', err));
💡 Tip: Replace 'your_api_key_here' with your actual API key found in your LinksTest account settings.