Short Links API

Tạo liên kết ngắn có thương hiệu với bí danh, hết hạn, mật khẩu, giới hạn nhấp chuột và phân tích.

Lấy API Key Mua tín dụng
Trường hợp sử dụng phổ biến
Theo dõi chiến dịch

Liên kết ngắn có thương hiệu cho các chiến dịch gắn thẻ UTM. Bí danh duy nhất cho mỗi đối tác để so sánh hiệu suất.

Mã QR

Mã thân thiện với in ấn mà bạn có thể thay đổi sau.

Bảo vệ bằng mật khẩu

Bảo vệ tài liệu nhạy cảm bằng mật khẩu đơn giản.

99.9 % Thời gian hoạt động
Phản hồi
25 req/s
0.002 Tín dụng / yêu cầu

Create Short Link (Basic)


POST https://api.yeb.to/v1/short-links/create-basic
Tham sốLoạiBắt buộcMô tả
api_key string Your API key
original_url string Target URL (scheme auto-added if missing)
alias string tùy chọn Human alias (1–100, [A-Za-z0-9\-_])
short_code string tùy chọn Custom short code (else auto 7 chars)
password string tùy chọn Optional access password
expires_at ISO 8601 tùy chọn Expiry timestamp
click_limit int tùy chọn Max total clicks
one_time bool tùy chọn Allow only a single click
settings array<{key,value}> tùy chọn Custom metadata

Ví dụ

curl -X POST https://api.yeb.to/v1/short-links/create-basic \
  -H "Content-Type: application/json" \
  -d '{
  "api_key": "YOUR_KEY",
  "original_url": "https://example.com/pricing",
  "alias": "docs-demo"
}'

Ví dụ phản hồi

Mã phản hồi

Mô tả
200 SuccessYêu cầu xử lý thành công.
400 Bad RequestXác thực đầu vào thất bại.
401 UnauthorizedAPI Key thiếu hoặc sai.
403 ForbiddenKey không hoạt động hoặc không được phép.
429 Rate LimitQuá nhiều yêu cầu.
500 Server ErrorLỗi không mong đợi.

Create Short Link (Advanced)


POST https://api.yeb.to/v1/short-links/create-advanced
Tham sốLoạiBắt buộcMô tả
api_key string Your API key
original_url string Target URL (scheme auto-added if missing)
alias string tùy chọn Human alias (1–100, [A-Za-z0-9\-_])
short_code string tùy chọn Custom short code (else auto 7 chars)
password string tùy chọn Optional access password
expires_at ISO 8601 tùy chọn Expiry timestamp
click_limit int tùy chọn Max total clicks
one_time bool tùy chọn Allow only a single click
settings array<{key,value}> tùy chọn Custom metadata

Ví dụ

curl -X POST https://api.yeb.to/v1/short-links/create-advanced \
  -H "Content-Type: application/json" \
  -d '{
  "api_key": "YOUR_KEY",
  "original_url": "https://example.com/pricing",
  "alias": "docs-demo",
  "click_limit": 100,
  "expires_at": "2025-12-31T23:59:00Z"
}'

Ví dụ phản hồi

Mã phản hồi

Mô tả
200 SuccessYêu cầu xử lý thành công.
400 Bad RequestXác thực đầu vào thất bại.
401 UnauthorizedAPI Key thiếu hoặc sai.
403 ForbiddenKey không hoạt động hoặc không được phép.
429 Rate LimitQuá nhiều yêu cầu.
500 Server ErrorLỗi không mong đợi.

Get Short Link


POST https://api.yeb.to/v1/short-links/get
Tham sốLoạiBắt buộcMô tả
api_key string Your API key
code string Alias or short_code

Ví dụ

curl -X POST https://api.yeb.to/v1/short-links/get \
  -H "Content-Type: application/json" \
  -d '{
  "api_key": "YOUR_KEY",
  "code": "docs-demo"
}'

Ví dụ phản hồi

Mã phản hồi

Mô tả
200 SuccessYêu cầu xử lý thành công.
400 Bad RequestXác thực đầu vào thất bại.
401 UnauthorizedAPI Key thiếu hoặc sai.
403 ForbiddenKey không hoạt động hoặc không được phép.
429 Rate LimitQuá nhiều yêu cầu.
500 Server ErrorLỗi không mong đợi.

Update Short Link


POST https://api.yeb.to/v1/short-links/update
Tham sốLoạiBắt buộcMô tả
api_key string Your API key
code string Alias or short_code to update
original_url string tùy chọn New target URL
alias string tùy chọn New alias
short_code string tùy chọn New short code
password string tùy chọn Set password (empty string to clear)
expires_at ISO 8601 tùy chọn New expiry
click_limit int tùy chọn New limit
one_time bool tùy chọn Enable/disable single-use
advanced_analytics bool tùy chọn Enable/disable advanced analytics
settings array<{key,value}> tùy chọn Replace settings

Ví dụ

curl -X POST https://api.yeb.to/v1/short-links/update \
  -H "Content-Type: application/json" \
  -d '{
  "api_key": "YOUR_KEY",
  "code": "docs-demo",
  "click_limit": 100,
  "expires_at": "2025-12-31T23:59:00Z"
}'

Ví dụ phản hồi

Mã phản hồi

Mô tả
200 SuccessYêu cầu xử lý thành công.
400 Bad RequestXác thực đầu vào thất bại.
401 UnauthorizedAPI Key thiếu hoặc sai.
403 ForbiddenKey không hoạt động hoặc không được phép.
429 Rate LimitQuá nhiều yêu cầu.
500 Server ErrorLỗi không mong đợi.

Delete Short Link


POST https://api.yeb.to/v1/short-links/delete
Tham sốLoạiBắt buộcMô tả
api_key string Your API key
code string Alias or short_code

Ví dụ

curl -X POST https://api.yeb.to/v1/short-links/delete \
  -H "Content-Type: application/json" \
  -d '{
  "api_key": "YOUR_KEY",
  "code": "docs-demo"
}'

Ví dụ phản hồi

Mã phản hồi

Mô tả
200 SuccessYêu cầu xử lý thành công.
400 Bad RequestXác thực đầu vào thất bại.
401 UnauthorizedAPI Key thiếu hoặc sai.
403 ForbiddenKey không hoạt động hoặc không được phép.
429 Rate LimitQuá nhiều yêu cầu.
500 Server ErrorLỗi không mong đợi.

Short Link Stats


POST https://api.yeb.to/v1/short-links/stats
Tham sốLoạiBắt buộcMô tả
api_key string Your API key
code string Alias or short_code
period enum tùy chọn `7d` | `30d` | `90d` (default: `30d`)
tz string tùy chọn Timezone label (informational)
limit_recent int tùy chọn Recent clicks to return (0–200, default 20)

Ví dụ

curl -X POST https://api.yeb.to/v1/short-links/stats \
  -H "Content-Type: application/json" \
  -d '{
  "api_key": "YOUR_KEY",
  "code": "docs-demo",
  "period": "30d",
  "limit_recent": 10
}'

Ví dụ phản hồi

Mã phản hồi

Mô tả
200 SuccessYêu cầu xử lý thành công.
400 Bad RequestXác thực đầu vào thất bại.
401 UnauthorizedAPI Key thiếu hoặc sai.
403 ForbiddenKey không hoạt động hoặc không được phép.
429 Rate LimitQuá nhiều yêu cầu.
500 Server ErrorLỗi không mong đợi.

Short Links API — Practical Guide

Create branded short links with optional password and expiry, manage aliases/codes safely, and read rich stats — without guessing which fields matter in production.

#What this API solves

Teams usually need more than “shorten this URL”. You want safe naming (alias vs code), campaign controls (expiry, one-time, click limits, password), and readable stats that answer “what’s working?”. This suite provides exactly that — with two creation modes (basic vs advanced) so you only pay for analytics you actually use.

#Endpoints & when to use them

#POST /v1/short-links/create-basic — Create link (cheaper)

  • Best for: Operational links where you only need totals & last click (fast & low cost).
  • Output: advanced_analytics=false, total_clicks may be present; no per-country/device buckets.

#POST /v1/short-links/create-advanced — Create link with rich analytics

  • Best for: Campaigns where you’ll later slice by country, device, browser, OS.
  • Output: advanced_analytics=true. The stats endpoint returns buckets.

#POST /v1/short-links/get — Fetch by alias or short_code

  • Ownership enforced: You’ll only see links owned by your API key/user.

#POST /v1/short-links/update — Change URL/alias/code/limits

  • Conflicts handled: Server rejects duplicate alias/short_code across live & soft-deleted rows.
  • Settings: Passing settings replaces the whole key/value set (idempotent).

#POST /v1/short-links/delete — Soft delete by code

  • Tip: Deleted aliases/codes still count for conflict checks to prevent accidental reuse collisions.

#POST /v1/short-links/stats — Summary & buckets

  • Period: 7d | 30d | 90d (default 30d).
  • Recent clicks: up to 200 latest (limit_recent).
  • Buckets: Country/Device/Browser/OS (when advanced_analytics=true).
  • Password metrics: When derivable, returns password_page_views_* and password_attempts_total.
  • Debug mode: Include "debug":true to surface query diagnostics in the response.

#Quick start

# Create a basic link
curl -sX POST "https://api.yeb.to/v1/short-links/create-basic" \
 -H "Accept: application/json" -H "Content-Type: application/json" \
 -d '{ "api_key":"<YOUR_KEY>", "original_url":"https://example.com/pricing", "alias":"docs-demo" }'
# Retrieve stats (30d default) with 10 recent clicks
curl -sX POST "https://api.yeb.to/v1/short-links/stats" \
 -H "Accept: application/json" -H "Content-Type: application/json" \
 -d '{ "api_key":"<YOUR_KEY>", "code":"docs-demo", "limit_recent":10 }'

#Full “everything on” request (covers most options)

Turn features on, then trim to your needs.

POST /v1/short-links/create-advanced
{
  "api_key": "YOUR_KEY",
  "original_url": "https://example.com/launch?utm_source=short",
  "alias": "docs-advanced-demo",
  "short_code": "AB12CDE",
  "password": "letmein",
  "expires_at": "2025-12-31T23:59:00Z",
  "click_limit": 1000,
  "one_time": false,
  "advanced_analytics": true,
  "settings": [
    {"key":"campaign","value":"winter-2025"},
    {"key":"owner","value":"growth-team"}
  ]
}

#Parameters that actually matter

Create / Update

ParamTypeRequiredPractical guidance
original_urlstring (URL)Yes (create)Scheme auto-added if missing; keep UTM here for external analytics.
aliasstringNoReadable path (e.g., /l/black-friday). Great for campaigns.
short_codestringNoFixed-length code. If omitted, server generates 7 chars. Use for printed collateral.
passwordstringNoGate sensitive pages. On update, send empty string to clear.
expires_atISO 8601NoHard stop for promo windows. Combine with stats to prune stale links.
click_limitintNoCap total visits (e.g., limited seats). Pair with one_time for single-use passes.
one_timeboolNoFirst successful click consumes the link.
advanced_analyticsboolNoEnable per-country/device/browser/OS buckets in /stats.
settingsarray<{key,value}>NoFree-form metadata. On update, the set is replaced atomically.

Stats request

ParamTypeRequiredNotes
codestringYesEither the alias or the short_code.
periodenumNo7d | 30d | 90d (default 30d).
limit_recentintNo0–200 (default 20). Returns latest clicks with IP/UA timestamped.
tzstringNoInformational field echoed back (visualization hint).
debugboolNotrue adds query diagnostics to response (helpful in staging).

#Reading & acting on responses

Create (basic vs advanced)

{
  "data": {
    "original_url": "https://example.com/pricing",
    "short_code": "AB12CDE",
    "alias": "docs-demo",
    "public_url": "https://yeb.to/l/docs-demo",
    "expires_at": null,
    "click_limit": null,
    "one_time": false,
    "advanced_analytics": false,
    "total_clicks": 0,
    "created_at": "2025-01-01T12:00:00Z",
    "updated_at": "2025-01-01T12:00:00Z"
  }
}
  • Print/embed: Use public_url on sites or QR codes.
  • Auditing: Keep alias and short_code in your DB for future updates.

Get / Update

{
  "data": {
    "original_url": "https://example.com/pricing",
    "short_code": "AB12CDE",
    "alias": "docs-demo",
    "public_url": "https://yeb.to/l/docs-demo",
    "expires_at": "2025-12-31T23:59:00Z",
    "click_limit": 100,
    "one_time": false,
    "advanced_analytics": false,
    "total_clicks": 0,
    "created_at": "2025-01-01T12:00:00Z",
    "updated_at": "2025-01-10T12:00:00Z"
  }
}
  • Conflicts: If you change alias or short_code to one that exists (even soft-deleted), you’ll get a 422 explaining the conflict.
  • Password: On update, send empty string to clear. Non-empty strings are stored hashed.

Stats

{
  "data": {
    "code": "docs-demo",
    "from": "2025-01-01T00:00:00Z",
    "to":   "2025-01-31T00:00:00Z",
    "tz": "UTC",
    "summary": {
      "total_clicks": 42,
      "last_click_at": "2025-01-30T20:05:00Z",
      "unique_countries": 8,
      "password_page_views_total": 12,
      "password_page_views_unique": 10,
      "password_attempts_total": 3
    },
    "recent_clicks": [
      {"ip":"1.2.3.4","user_agent":"...","ts":"2025-01-30T20:05:00Z"}
    ],
    "by_country": [{"key":"US","count":20}],
    "by_device":  [{"key":"mobile","count":30}],
    "by_browser": [{"key":"Chrome","count":25}],
    "by_os":      [{"key":"Android","count":18}]
  }
}
  • Basic vs Advanced: Buckets populate only when the link was created with advanced_analytics=true and underlying tables exist.
  • Recent list: Use it for moderation/debugging; don’t store full UA/IP long-term if you don’t need them.

#Practical recipes

  • Campaign naming: Use alias for human-readable slugs (/l/summer-sale), keep short_code for printed QR where length matters.
  • Time-boxed promos: Set expires_at and click_limit. After the window, update the link to a “campaign over” page.
  • Single-use access: Combine one_time=true with a password. Track attempts via /stats password metrics.
  • Attribution: Include UTMs in original_url. The API doesn’t change your query string.
  • Governance: Store settings like campaign, owner, cost_center for internal reporting.

#Errors & safeguards

  • 422 — Validation (missing original_url, code, or alias/code conflict).
  • 404 — Not found (wrong code or not owned by your key/user).
  • Ownership: All read/write endpoints scope by API key/user; non-owned links behave as “not found”.

#API Changelog (Short Links)

2025-11-05
Stats diagnostics. Added optional debug flag to /stats response for query introspection.
2025-11-03
Password telemetry. Surfacing password_page_views_* and password_attempts_total when derivable.
2025-10-28
Conflict hardening. Update now checks duplicates across live & soft-deleted links; clearer 422 messages.
2025-10-20
Advanced analytics path. Split creation into create-basic and create-advanced with bucketed stats support.

Use the endpoint playgrounds on this page to test payloads and lock defaults (alias pattern, expiry policy, analytics mode).

#Copy-ready cURL (common flows)

# Create (basic)
curl -sX POST "https://api.yeb.to/v1/short-links/create-basic" -H "Content-Type: application/json" \
 -d '{"api_key":"YOUR_KEY","original_url":"https://example.com/pricing","alias":"docs-demo"}'

# Create (advanced)
curl -sX POST "https://api.yeb.to/v1/short-links/create-advanced" -H "Content-Type: application/json" \
 -d '{"api_key":"YOUR_KEY","original_url":"https://example.com/pricing","alias":"docs-demo","click_limit":100,"expires_at":"2025-12-31T23:59:00Z"}'

# Get
curl -sX POST "https://api.yeb.to/v1/short-links/get" -H "Content-Type: application/json" \
 -d '{"api_key":"YOUR_KEY","code":"docs-demo"}'

# Update
curl -sX POST "https://api.yeb.to/v1/short-links/update" -H "Content-Type: application/json" \
 -d '{"api_key":"YOUR_KEY","code":"docs-demo","click_limit":100,"expires_at":"2025-12-31T23:59:00Z"}'

# Stats
curl -sX POST "https://api.yeb.to/v1/short-links/stats" -H "Content-Type: application/json" \
 -d '{"api_key":"YOUR_KEY","code":"docs-demo","period":"30d","limit_recent":10}'

# Delete
curl -sX POST "https://api.yeb.to/v1/short-links/delete" -H "Content-Type: application/json" \
 -d '{"api_key":"YOUR_KEY","code":"docs-demo"}'

Câu hỏi thường gặp

Dữ liệu MaxMind GeoLite2 thường chính xác đến cấp thành phố cho 65–70% địa chỉ IPv4 trên toàn thế giới.

Vì quyền riêng tư và sự đơn giản, chúng tôi chuẩn hóa tất cả trạng thái "không khả dụng" (hết hạn, đã sử dụng, bị vô hiệu hóa, đạt giới hạn nhấp chuột) thành 404.

Có, nếu alias/short_code mới là duy nhất trong cả hai cột. API thực thi tính duy nhất toàn cầu.

Burst mặc định là 20 yêu cầu/giây mỗi API key (có thể thay đổi theo gói). Hạn mức hàng ngày và hàng tháng cũng có thể áp dụng.

Tạo liên kết tiêu tốn tín dụng. Xem thống kê cũng vậy. Lượt xem/thử mật khẩu được ghi lại nhưng không tính phí riêng lẻ.

Lượt nhấp duy nhất được ước tính dựa trên các địa chỉ IP khác nhau được quan sát trước sự kiện hiện tại.

Chỉ bạn. Kiểm tra truy cập khớp với user_id của bạn (web) hoặc bất kỳ API key nào bạn sở hữu (API). Yêu cầu từ người khác được hiển thị là 404.

Có. Mọi yêu cầu, kể cả những yêu cầu có lỗi, đều tiêu tốn tín dụng. Tín dụng của bạn được gắn với số lượng yêu cầu, bất kể thành công hay thất bại. Nếu lỗi rõ ràng do sự cố nền tảng từ phía chúng tôi, chúng tôi sẽ khôi phục tín dụng bị ảnh hưởng (không hoàn tiền mặt).

Liên hệ chúng tôi tại [email protected]. Chúng tôi coi trọng phản hồi—nếu báo cáo lỗi hoặc yêu cầu tính năng của bạn có ý nghĩa, chúng tôi có thể sửa hoặc cải thiện API nhanh chóng và tặng bạn 50 tín dụng miễn phí để cảm ơn.

Tùy thuộc vào API và đôi khi cả endpoint. Một số endpoint sử dụng dữ liệu từ nguồn bên ngoài, có thể có giới hạn nghiêm ngặt hơn. Chúng tôi cũng áp dụng giới hạn để ngăn chặn lạm dụng và duy trì sự ổn định của nền tảng. Kiểm tra tài liệu để biết giới hạn cụ thể cho mỗi endpoint.

Chúng tôi hoạt động theo hệ thống tín dụng. Tín dụng là các đơn vị trả trước, không hoàn lại mà bạn chi cho các cuộc gọi API và công cụ. Tín dụng được tiêu thụ theo FIFO (cũ nhất trước) và có hiệu lực 12 tháng kể từ ngày mua. Bảng điều khiển hiển thị ngày mua và ngày hết hạn của mỗi giao dịch.

Có. Tất cả tín dụng đã mua (bao gồm số dư lẻ) có hiệu lực 12 tháng kể từ ngày mua. Tín dụng chưa sử dụng tự động hết hạn và bị xóa vĩnh viễn khi kết thúc thời hạn hiệu lực. Tín dụng đã hết hạn không thể khôi phục hoặc chuyển đổi thành tiền mặt hay giá trị khác. Quy tắc chuyển tiếp: tín dụng mua trước ngày 22 tháng 9 năm 2025 được coi là mua vào ngày 22 tháng 9 năm 2025 và hết hạn vào ngày 22 tháng 9 năm 2026 (trừ khi ngày hết hạn sớm hơn được ghi khi mua).

Có—trong thời hạn hiệu lực. Tín dụng chưa sử dụng vẫn khả dụng và được chuyển từ tháng sang tháng cho đến khi hết hạn 12 tháng sau khi mua.

Tín dụng là không hoàn lại. Chỉ mua những gì bạn cần—bạn luôn có thể nạp thêm sau. Nếu lỗi nền tảng gây ra tính phí thất bại, chúng tôi có thể khôi phục tín dụng bị ảnh hưởng sau khi điều tra. Không hoàn tiền mặt.

Giá được tính bằng tín dụng, không phải đô la. Mỗi endpoint có chi phí riêng—xem huy hiệu "Tín dụng / yêu cầu" ở trên. Bạn luôn biết chính xác mình đang chi bao nhiêu.
← Quay lại API