Short Links API

エイリアス、有効期限、パスワード、クリック制限、分析機能を備えたブランド短縮リンクを作成します。

一般的なユースケース
キャンペーン追跡

UTMタグ付きキャンペーン用の短いブランドリンク。パートナーごとのユニークなエイリアスでパフォーマンスを比較。

QRコード

後から変更できる印刷対応コード。

パスワード保護

シンプルなパスワードで機密文書を保護します。

99.9 % 稼働時間
レスポンス
25 req/s
0.002 クレジット / リクエスト

Create Short Link (Basic)


POST https://api.yeb.to/v1/short-links/create-basic
パラメータ必須説明
api_key string はい Your API key
original_url string はい Target URL (scheme auto-added if missing)
alias string 任意 Human alias (1–100, [A-Za-z0-9\-_])
short_code string 任意 Custom short code (else auto 7 chars)
password string 任意 Optional access password
expires_at ISO 8601 任意 Expiry timestamp
click_limit int 任意 Max total clicks
one_time bool 任意 Allow only a single click
settings array<{key,value}> 任意 Custom metadata

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"
}'

レスポンス例

レスポンスコード

コード説明
200 Successリクエスト処理成功。
400 Bad Request入力バリデーション失敗。
401 UnauthorizedAPIキーが不足または不正。
403 Forbiddenキーが無効または許可されていません。
429 Rate Limitリクエストが多すぎます。
500 Server Error予期しないエラー。

Create Short Link (Advanced)


POST https://api.yeb.to/v1/short-links/create-advanced
パラメータ必須説明
api_key string はい Your API key
original_url string はい Target URL (scheme auto-added if missing)
alias string 任意 Human alias (1–100, [A-Za-z0-9\-_])
short_code string 任意 Custom short code (else auto 7 chars)
password string 任意 Optional access password
expires_at ISO 8601 任意 Expiry timestamp
click_limit int 任意 Max total clicks
one_time bool 任意 Allow only a single click
settings array<{key,value}> 任意 Custom metadata

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"
}'

レスポンス例

レスポンスコード

コード説明
200 Successリクエスト処理成功。
400 Bad Request入力バリデーション失敗。
401 UnauthorizedAPIキーが不足または不正。
403 Forbiddenキーが無効または許可されていません。
429 Rate Limitリクエストが多すぎます。
500 Server Error予期しないエラー。

Get Short Link


POST https://api.yeb.to/v1/short-links/get
パラメータ必須説明
api_key string はい Your API key
code string はい Alias or short_code

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

レスポンス例

レスポンスコード

コード説明
200 Successリクエスト処理成功。
400 Bad Request入力バリデーション失敗。
401 UnauthorizedAPIキーが不足または不正。
403 Forbiddenキーが無効または許可されていません。
429 Rate Limitリクエストが多すぎます。
500 Server Error予期しないエラー。

Update Short Link


POST https://api.yeb.to/v1/short-links/update
パラメータ必須説明
api_key string はい Your API key
code string はい Alias or short_code to update
original_url string 任意 New target URL
alias string 任意 New alias
short_code string 任意 New short code
password string 任意 Set password (empty string to clear)
expires_at ISO 8601 任意 New expiry
click_limit int 任意 New limit
one_time bool 任意 Enable/disable single-use
advanced_analytics bool 任意 Enable/disable advanced analytics
settings array<{key,value}> 任意 Replace settings

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"
}'

レスポンス例

レスポンスコード

コード説明
200 Successリクエスト処理成功。
400 Bad Request入力バリデーション失敗。
401 UnauthorizedAPIキーが不足または不正。
403 Forbiddenキーが無効または許可されていません。
429 Rate Limitリクエストが多すぎます。
500 Server Error予期しないエラー。

Delete Short Link


POST https://api.yeb.to/v1/short-links/delete
パラメータ必須説明
api_key string はい Your API key
code string はい Alias or short_code

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

レスポンス例

レスポンスコード

コード説明
200 Successリクエスト処理成功。
400 Bad Request入力バリデーション失敗。
401 UnauthorizedAPIキーが不足または不正。
403 Forbiddenキーが無効または許可されていません。
429 Rate Limitリクエストが多すぎます。
500 Server Error予期しないエラー。

Short Link Stats


POST https://api.yeb.to/v1/short-links/stats
パラメータ必須説明
api_key string はい Your API key
code string はい Alias or short_code
period enum 任意 `7d` | `30d` | `90d` (default: `30d`)
tz string 任意 Timezone label (informational)
limit_recent int 任意 Recent clicks to return (0–200, default 20)

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
}'

レスポンス例

レスポンスコード

コード説明
200 Successリクエスト処理成功。
400 Bad Request入力バリデーション失敗。
401 UnauthorizedAPIキーが不足または不正。
403 Forbiddenキーが無効または許可されていません。
429 Rate Limitリクエストが多すぎます。
500 Server Error予期しないエラー。

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"}'

よくある質問

MaxMind GeoLite2のデータは、世界中のIPv4アドレスの65〜70%において市区町村レベルで正確です。

プライバシーとシンプルさのため、すべての「利用不可」状態(期限切れ、消費済み、無効、クリック制限到達)を404に統一しています。

はい、新しいalias/short_codeが両方のカラムで一意であれば可能です。APIはグローバルな一意性を強制します。

デフォルトのバーストはAPIキーあたり20リクエスト/秒です(プランにより異なる場合があります)。日次および月次のクォータも適用される場合があります。

リンクの作成でクレジットが消費されます。統計の閲覧でも同様です。パスワードの閲覧/試行自体は記録されますが、個別に課金されることはありません。

ユニーク数は、現在のイベント前に観測された異なるIPアドレスによって概算されます。

あなただけです。アクセスチェックはあなたのuser_id(Web)または所有するAPIキー(API)と照合されます。他者からのリクエストは404として処理されます。

はい。エラーが発生したリクエストを含め、すべてのリクエストがクレジットを消費します。クレジットは成功・失敗に関係なくリクエスト数に紐づいています。エラーが明らかに当社のプラットフォーム側の問題による場合は、影響を受けたクレジットを復元します(現金での返金はありません)。

[email protected]までご連絡ください。フィードバックを真摯に受け止めています。バグレポートや機能リクエストが意味のあるものであれば、APIを迅速に修正・改善し、お礼として50の無料クレジットを付与します。

APIやエンドポイントによって異なります。一部のエンドポイントは外部ソースのデータを使用しており、より厳しい制限がある場合があります。また、不正利用の防止とプラットフォームの安定性維持のために制限を設けています。各エンドポイントの具体的な制限についてはドキュメントをご確認ください。

クレジットシステムで運営しています。クレジットは前払いの返金不可の単位で、API呼び出しやツールに使用します。クレジットはFIFO(古いものから順に)消費され、購入日から12か月間有効です。ダッシュボードに各購入日とその有効期限が表示されます。

はい。購入したすべてのクレジット(端数残高を含む)は購入から12か月間有効です。未使用のクレジットは有効期間終了時に自動的に期限切れとなり、永久に削除されます。期限切れのクレジットは復元や現金その他の価値への変換はできません。経過措置:2025年9月22日以前に購入したクレジットは2025年9月22日購入として扱われ、2026年9月22日に期限切れとなります(購入時により早い期限が記載されていない限り)。

はい—有効期間内で繰り越されます。未使用のクレジットは利用可能な状態のまま月ごとに繰り越され、購入後12か月で期限切れになります。

クレジットは返金不可です。必要な分だけ購入してください—後からいつでもチャージできます。プラットフォーム側のエラーで課金に失敗した場合、調査後に影響を受けたクレジットを復元する場合があります。現金での返金はありません。

料金はドルではなくクレジットで設定されています。各エンドポイントには独自のコストがあります—上記の「クレジット / リクエスト」バッジをご覧ください。常に正確な支出額がわかります。
← APIに戻る