API Reference
Overview
LinkPilot API cho phép bạn quản lý short links, domains và analytics thông qua các endpoint RESTful.
Base URL
https://linkpilot.theyourlist.com/api/v1Authentication
Mọi request đều yêu cầu API Key. Có 2 cách truyền key:
Header (Khuyến nghị)
Authorization: Bearer lp_your_api_key_hereQuery Parameter
GET /api/v1/links?api_key=lp_your_api_key_hereResponse khi không xác thực
{
"success": false,
"error": "Unauthorized"
}HTTP Status: 401 Unauthorized
Response Format
Thành công
{
"success": true,
"data": { ... }
}Lỗi
{
"success": false,
"error": "Error message here"
}Endpoints
GET/api/v1/links
Lấy danh sách links
Query Parameters
| Parameter | Type | Description |
|---|---|---|
page | number | Trang hiện tại (default: 1) |
limit | number | Số item mỗi trang (default: 20, max: 100) |
domain_id | string | Lọc theo domain |
search | string | Tìm theo tên hoặc slug |
POST/api/v1/links
Tạo link mới
Request Body
{
"name": "Shopee Christmas Sale",
"slug": "xmas-sale",
"default_url": "https://shopee.vn/sale/christmas",
"domain_id": "clxxx...",
"is_enabled": true,
"expires_at": "2025-12-31T23:59:59Z",
"geo_targets": [
{
"country_code": "VN",
"target_url": "https://shopee.vn/sale"
}
]
}GET/api/v1/links/{id}
Lấy chi tiết link
PUT/api/v1/links/{id}
Cập nhật link
DELETE/api/v1/links/{id}
Xóa link
GET/api/v1/domains
Lấy danh sách domains
POST/api/v1/domains
Thêm domain mới
GET/api/v1/links/{id}/analytics
Lấy analytics của link
Query Parameters
| Parameter | Type | Description |
|---|---|---|
start_date | string | Ngày bắt đầu (YYYY-MM-DD) |
end_date | string | Ngày kết thúc (YYYY-MM-DD) |
group_by | string | Nhóm theo: day, country, referer |
GET/api/v1/stats
Lấy thống kê tổng quan
Error Codes
| HTTP Status | Error | Description |
|---|---|---|
400 | Bad Request | Request không hợp lệ |
401 | Unauthorized | Thiếu hoặc sai API Key |
403 | Forbidden | Không có quyền truy cập |
404 | Not Found | Resource không tồn tại |
409 | Conflict | Duplicate (VD: slug đã tồn tại) |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Lỗi server |
Code Examples
cURL
curl -X POST "https://linkpilot.theyourlist.com/api/v1/links" \
-H "Authorization: Bearer lp_your_api_key" \
-H "Content-Type: application/json" \
-d '{"name":"Test Link","slug":"test","default_url":"https://google.com","domain_id":"clxxx"}'JavaScript
const response = await fetch('https://linkpilot.theyourlist.com/api/v1/links', {
method: 'POST',
headers: {
'Authorization': 'Bearer lp_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Test Link',
slug: 'test',
default_url: 'https://google.com',
domain_id: 'clxxx'
})
});
const data = await response.json();
console.log(data);Python
import requests
response = requests.post(
'https://linkpilot.theyourlist.com/api/v1/links',
headers={
'Authorization': 'Bearer lp_your_api_key',
'Content-Type': 'application/json'
},
json={
'name': 'Test Link',
'slug': 'test',
'default_url': 'https://google.com',
'domain_id': 'clxxx'
}
)
print(response.json())PHP
<?php
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://linkpilot.theyourlist.com/api/v1/links',
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer lp_your_api_key',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Test Link',
'slug' => 'test',
'default_url' => 'https://google.com',
'domain_id' => 'clxxx'
]),
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));Rate Limiting
- Limit: 1000 requests / phút / API Key
- Headers:
X-RateLimit-Limit: Giới hạnX-RateLimit-Remaining: Số request còn lạiX-RateLimit-Reset: Thời điểm reset (Unix timestamp)