API rút gọn liên kết - tài liệu

API JSON để tạo và tra cứu liên kết rút gọn. Dùng khóa API của tài khoản (hoặc API_TOKEN nền tảng nếu có).

API công khai: https://anyurl.bond - JSON tại /api/v1/.

Authorization

Authorization: Bearer 1234

Gửi đúng khóa API trong Authorization: Bearer. Đăng nhập bảng điều khiển dùng cùng khóa với email.

POST /api/v1/shorten

{"long_url":"https://example.com","expiration_time":"24h","max_uses":100,"allow_bots":false}
{"long_url":"https://example.com","permanent":true}

expiration_time và max_uses tùy chọn cho gói trả phí. Không trả phí có trần theo tháng dương lịch (UTC, reset ngày 1) và mỗi liên kết hết hạn ~10 phút bất kể nội dung yêu cầu.

GET /api/v1/info/{short_code}

Trả về siêu dữ liệu và tính hợp lệ của mã rút gọn mà không tăng số lượt nhấp.

GET /api/v1/me

Trả về gói của bạn, hạn mức hiệu lực từ bảng điều khiển và mức dùng tháng hiện tại (UTC): liên kết mới và chỉnh sửa qua API.

GET /api/v1/links

?limit=50&offset=0

Chỉ liệt kê liên kết rút gọn tạo bằng khóa API tài khoản (owner_id khớp khóa đó; cùng phạm vi GET /info). Token API nền tảng không gọi được endpoint này. Truy vấn tùy chọn: limit (mặc định 50, tối đa 100), offset (mặc định 0, tối đa 100000). JSON: links (cùng trường GET /info mỗi phần tử), total, limit, offset. Danh sách không xóa dòng hay tăng nhấp.

PUT / PATCH /api/v1/info/{short_code}

{"long_url":"https://example.com/new","expiration_time":"24h","max_uses":20,"allow_bots":false}

Để đổi mã rút gọn đã có, dùng PUT hoặc PATCH tại /api/v1/info/{short_code} - không phải POST /shorten. Thân JSON: bất kỳ trong long_url, expiration_time, max_uses, allow_bots. Bỏ qua trường để giữ nguyên. Xóa hết hạn thời gian bằng expiration_time ""; không giới hạn lượt với max_uses -1. Hình dạng phản hồi giống GET /info.

Ví dụ dòng lệnh (curl)

Token 1234 chỉ là ví dụ - dùng khóa API thật của bạn. Máy chủ: https://anyurl.bond.

POST /api/v1/shorten - JSON đầy đủ (máy chủ https://anyurl.bond)
curl
curl -sS -X POST 'https://anyurl.bond/api/v1/shorten' \
  -H 'Authorization: Bearer 1234' \
  -H 'Content-Type: application/json' \
  -d "{\"long_url\":\"https://example.com\",\"expiration_time\":\"24h\",\"max_uses\":100,\"allow_bots\":false}"
POST /api/v1/shorten - thân tối thiểu (trả phí: mặc định hết hạn 24 giờ)
curl
curl -sS -X POST 'https://anyurl.bond/api/v1/shorten' \
  -H 'Authorization: Bearer 1234' \
  -H 'Content-Type: application/json' \
  -d "{\"long_url\":\"https://example.com\"}"
POST /api/v1/shorten - vĩnh viễn (trả phí; tốn một lần chỉnh sửa thông minh)
curl
curl -sS -X POST 'https://anyurl.bond/api/v1/shorten' \
  -H 'Authorization: Bearer 1234' \
  -H 'Content-Type: application/json' \
  -d "{\"long_url\":\"https://example.com\",\"permanent\":true}"
GET /api/v1/info/{short_code} - ví dụ mã rút gọn abc123
curl
curl -sS 'https://anyurl.bond/api/v1/info/abc123' \
  -H 'Authorization: Bearer 1234'
GET /api/v1/me
curl
curl -sS 'https://anyurl.bond/api/v1/me' \
  -H 'Authorization: Bearer 1234'
GET /api/v1/links - phân trang liên kết rút gọn của bạn
curl
curl -sS 'https://anyurl.bond/api/v1/links?limit=50&offset=0' \
  -H 'Authorization: Bearer 1234'
PATCH /api/v1/info/{short_code}
curl
curl -sS -X PATCH 'https://anyurl.bond/api/v1/info/abc123' \
  -H 'Authorization: Bearer 1234' \
  -H 'Content-Type: application/json' \
  -d "{\"long_url\":\"https://example.com/updated-destination\"}"
PUT /api/v1/info/{short_code}
curl
curl -sS -X PUT 'https://anyurl.bond/api/v1/info/abc123' \
  -H 'Authorization: Bearer 1234' \
  -H 'Content-Type: application/json' \
  -d "{\"long_url\":\"https://example.com/updated\",\"expiration_time\":\"7d\",\"max_uses\":50,\"allow_bots\":true}"
Verbose (-v) để gỡ lỗi
curl
curl -v -X POST 'https://anyurl.bond/api/v1/shorten' \
  -H 'Authorization: Bearer 1234' \
  -H 'Content-Type: application/json' \
  -d "{\"long_url\":\"https://example.com\"}"

Gói API miễn phí: tối đa 100 liên kết rút gọn mới mỗi tháng dương lịch (UTC); hạn mức reset vào ngày 1. Mỗi liên kết hết hạn sau khoảng 10 phút. Gói trả phí dùng cùng chu kỳ tháng.

Về trang chủ · Điều khoản và điều kiện