API Documentation

Integrate LinksTest into your applications with our simple, powerful REST API.

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

ParameterTypeDescriptionRequired
urlstringURL to testRequired
countrystring2-letter ISO country codeRequired
devicestring"Android", "iOS", "Mac", "Windows"Required
versionstringOptional OS version hintOptional
citystringOptional city overrideOptional

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.

Common Errors

ErrorStatusDescription
Invalid or missing API Key401Authentication failed
Insufficient credits401Not enough credits for this request
API access not enabled403Current plan does not include API access
Invalid data format400Invalid or malformed request data
Missing test object400'test' is required and must be an array
Missing required fields400Every test must include 'url', 'country', and 'device'
Test not found404Invalid test_id when checking status
Invalid URL400The provided URL is not valid
Invalid country400Country code is not recognized
Invalid device400Device type is not valid
Method not allowed405HTTP method not supported for this endpoint
Endpoint not found404The requested endpoint does not exist