Phiên bản v1 · Cập nhật lần cuối: 2025
Tích hợp tính năng rút gọn link LinkShort vào ứng dụng, website, hoặc workflow của bạn chỉ trong vài phút. API cung cấp đầy đủ chức năng tạo, quản lý và theo dõi link rút gọn.
API chỉ khả dụng với các gói trả phí sau. Gói Cơ Bản (Free) và Pro không có quyền truy cập API.
Tất cả API endpoint đều có tiền tố sau. API chỉ hoạt động tại domain chính thức.
https://rutgon.vmeta.vn/api/v1Mọi request đến API đều phải kèm theo API key qua một trong hai cách sau:
Cách 1 — Header X-API-Key (khuyến nghị)
curl https://rutgon.vmeta.vn/api/v1/links \
-H "X-API-Key: ls_live_YOUR_API_KEY_HERE"Cách 2 — Header Authorization: Bearer
curl https://rutgon.vmeta.vn/api/v1/links \
-H "Authorization: Bearer ls_live_YOUR_API_KEY_HERE"Bảo mật key của bạn. Không chia sẻ API key trên client-side (JavaScript trình duyệt, mobile app không bảo mật). Chỉ gọi API từ server-side (backend, webhook, serverless functions).
ls_live_xxxxxxxxxx....env). Key chỉ hiển thị một lần khi cấp lại.Tất cả response đều là JSON với Content-Type: application/json.
Response thành công
{
"data": { ... }, // Đối với endpoint đơn lẻ
"data": [ ... ], // Đối với endpoint danh sách
"meta": { // Đính kèm khi phân trang
"total": 42,
"page": 1,
"limit": 20,
"totalPages": 3
}
}Response lỗi
{
"error": "Mô tả lỗi",
"code": "ERROR_CODE" // Mã lỗi để xử lý trong code
}/linksDanh sách linkLấy danh sách tất cả link thuộc tài khoản, hỗ trợ tìm kiếm và phân trang.
Query parameters
| Tham số | Kiểu | Mô tả |
|---|---|---|
| page | integer | Trang hiện tại (mặc định: 1) |
| limit | integer | Số kết quả mỗi trang, tối đa 100 (mặc định: 20) |
| search | string | Tìm theo tiêu đề, URL gốc, hoặc mã rút gọn |
Ví dụ request
curl "https://rutgon.vmeta.vn/api/v1/links?page=1&limit=10&search=facebook" \
-H "X-API-Key: ls_live_YOUR_API_KEY"Response 200
{
"data": [
{
"id": "clxyz123",
"shortCode": "abc123",
"shortUrl": "https://rutgon.vmeta.vn/p/abc123",
"originalUrl": "https://facebook.com/example",
"title": "Trang Facebook",
"isActive": true,
"expiresAt": null,
"maxClicks": null,
"clicks": 142,
"createdAt": "2025-01-15T08:30:00.000Z",
"updatedAt": "2025-01-15T08:30:00.000Z"
}
],
"meta": {
"total": 42,
"page": 1,
"limit": 10,
"totalPages": 5
}
}/linksTạo link mớiTạo một link rút gọn mới.
Request body (JSON)
| Trường | Bắt buộc | Mô tả |
|---|---|---|
| originalUrl | Bắt buộc | URL đích đầy đủ (bắt đầu bằng https://) |
| customCode | Tuỳ chọn | Mã rút gọn tự chọn (3-190 ký tự, a-z A-Z 0-9). Nếu bỏ trống hệ thống tự tạo. |
| title | Tuỳ chọn | Tiêu đề cho link (tối đa 100 ký tự) |
| expiresAt | Tuỳ chọn | Thời điểm hết hạn (ISO 8601, ví dụ: 2025-12-31T23:59:59Z) |
| password | Tuỳ chọn | Mật khẩu bảo vệ link |
| maxClicks | Tuỳ chọn | Số lần click tối đa, link tự ngừng sau khi đạt giới hạn |
Ví dụ request
curl -X POST "https://rutgon.vmeta.vn/api/v1/links" \
-H "X-API-Key: ls_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"originalUrl": "https://example.com/very-long-url",
"title": "Trang chủ Example",
"customCode": "ex-home",
"expiresAt": "2025-12-31T23:59:59Z",
"maxClicks": 1000
}'Response 201 — Created
{
"data": {
"id": "clxyz456",
"shortCode": "ex-home",
"shortUrl": "https://rutgon.vmeta.vn/p/ex-home",
"originalUrl": "https://example.com/very-long-url",
"title": "Trang chủ Example",
"isActive": true,
"expiresAt": "2025-12-31T23:59:59.000Z",
"maxClicks": 1000,
"clicks": 0,
"createdAt": "2025-03-22T10:00:00.000Z",
"updatedAt": "2025-03-22T10:00:00.000Z"
}
}/links/:idChi tiết linkLấy thông tin chi tiết của một link theo ID.
Ví dụ request
curl "https://rutgon.vmeta.vn/api/v1/links/clxyz456" \
-H "X-API-Key: ls_live_YOUR_API_KEY"Response 200
{
"data": {
"id": "clxyz456",
"shortCode": "ex-home",
"shortUrl": "https://rutgon.vmeta.vn/p/ex-home",
"originalUrl": "https://example.com/very-long-url",
"title": "Trang chủ Example",
"isActive": true,
"expiresAt": "2025-12-31T23:59:59.000Z",
"maxClicks": 1000,
"clicks": 47,
"createdAt": "2025-03-22T10:00:00.000Z",
"updatedAt": "2025-03-22T10:00:00.000Z"
}
}/links/:idCập nhật linkCập nhật thông tin link. Chỉ truyền các trường cần thay đổi.
Request body
| Trường | Mô tả |
|---|---|
| title | Tiêu đề mới |
| isActive | Bật/tắt link (true/false) |
| expiresAt | Ngày hết hạn mới (ISO 8601 hoặc null để xoá) |
| maxClicks | Giới hạn click mới (số nguyên hoặc null để xoá) |
Ví dụ — Tắt link
curl -X PATCH "https://rutgon.vmeta.vn/api/v1/links/clxyz456" \
-H "X-API-Key: ls_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "isActive": false }'Ví dụ — Xoá ngày hết hạn
curl -X PATCH "https://rutgon.vmeta.vn/api/v1/links/clxyz456" \
-H "X-API-Key: ls_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "expiresAt": null }'/links/:idXoá linkXoá vĩnh viễn một link. Thao tác này không thể hoàn tác.
Ví dụ request
curl -X DELETE "https://rutgon.vmeta.vn/api/v1/links/clxyz456" \
-H "X-API-Key: ls_live_YOUR_API_KEY"Response 200
{ "ok": true, "message": "Link đã được xoá" }| HTTP Status | code | Ý nghĩa |
|---|---|---|
| 200 | — | Thành công |
| 201 | — | Tạo mới thành công |
| 400 | — | Request không hợp lệ (sai tham số, URL sai định dạng...) |
| 401 | MISSING_API_KEY | Không có API key trong request |
| 401 | INVALID_API_KEY | API key sai hoặc đã bị thu hồi |
| 403 | INVALID_HOST | Request không đến từ domain cho phép (rutgon.vmeta.vn) |
| 403 | PLAN_NOT_SUPPORTED | Gói dịch vụ không hỗ trợ API (cần Ultra / Ultra+) |
| 404 | — | Link không tồn tại hoặc không thuộc tài khoản |
| 409 | — | Mã rút gọn đã tồn tại |
| 500 | — | Lỗi server nội bộ |
Node.js / TypeScript
const API_KEY = process.env.LINKSHORT_API_KEY // ls_live_xxx
const BASE = 'https://rutgon.vmeta.vn/api/v1'
async function shortenUrl(originalUrl: string, title?: string) {
const res = await fetch(`${BASE}/links`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY!,
'Content-Type': 'application/json',
},
body: JSON.stringify({ originalUrl, title }),
})
if (!res.ok) {
const err = await res.json()
throw new Error(err.error)
}
const { data } = await res.json()
return data.shortUrl // "https://rutgon.vmeta.vn/p/abc123"
}
// Sử dụng
const shortUrl = await shortenUrl('https://example.com/very/long/path', 'Trang chủ')
console.log(shortUrl)Python
import os
import requests
API_KEY = os.environ['LINKSHORT_API_KEY'] # ls_live_xxx
BASE = 'https://rutgon.vmeta.vn/api/v1'
def shorten_url(original_url: str, title: str = None) -> str:
response = requests.post(
f'{BASE}/links',
headers={'X-API-Key': API_KEY, 'Content-Type': 'application/json'},
json={'originalUrl': original_url, 'title': title},
)
response.raise_for_status()
return response.json()['data']['shortUrl']
# Sử dụng
short_url = shorten_url('https://example.com/very/long/path', 'Trang chủ')
print(short_url) # https://rutgon.vmeta.vn/p/abc123PHP
<?php
$apiKey = getenv('LINKSHORT_API_KEY'); // ls_live_xxx
$base = 'https://rutgon.vmeta.vn/api/v1';
function shortenUrl(string $url, string $title = ''): string {
global $apiKey, $base;
$ch = curl_init("$base/links");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ["X-API-Key: $apiKey", 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['originalUrl' => $url, 'title' => $title]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
return $body['data']['shortUrl'];
}
echo shortenUrl('https://example.com/very/long/path', 'Trang chủ');
// https://rutgon.vmeta.vn/p/abc123Liên hệ đội ngũ hỗ trợ nếu bạn gặp khó khăn trong quá trình tích hợp API.