Developer API Reference

Minimalist RESTful API, integrate short links in two steps.

Developer API Reference

dco.ink provides an extremely streamlined REST API, allowing you to integrate short link functionality into any application. Our API authentication has only two modes:

Mode 1: Without Token

If you just want to generate short links and don’t care about subsequent management, you can call the generation endpoint directly. No authentication is required.

Example code:

curl -X POST https://api.dco.ink/api/links \
  -d '{"url": "https://example.com/very-long-url"}'
  • Pros: Zero barrier, takes effect immediately.
  • Cons: The generated short links will not appear in your dashboard and cannot be tracked or managed.

Mode 2: With Token (For Management)

If you want the generated short links to be recorded under your account for future tracking, modification, or deletion, you need to include the API Token obtained from your dashboard in the request header:

Example code (With Token):

curl -X POST https://api.dco.ink/api/links \
  -H "Authorization: Bearer dco_YOUR_TOKEN" \
  -d '{"url": "https://example.com/very-long-url"}'

Endpoint: POST https://api.dco.ink/api/links

ParameterTypeDescription
urlstring[Required] Target long URL.
custom_codestring[Optional] Custom branded short code.

Request Example 1: Without Token No Authorization header required:

curl -X POST https://api.dco.ink/api/links \
  -d '{"url": "https://example.com/very-long-url"}'

Request Example 2: Bind Account and Use Custom Code (With Token)

curl -X POST https://api.dco.ink/api/links \
  -H "Authorization: Bearer dco_YOUR_TOKEN" \
  -d '{"url": "https://example.com/very-long-url", "custom_code": "mybrand"}'

Endpoint: GET https://api.dco.ink/api/links Retrieve all short links created under your account. Supports pagination.

Request Example (With Token):

curl -X GET "https://api.dco.ink/api/links?limit=50&offset=0" \
  -H "Authorization: Bearer dco_YOUR_TOKEN"

3. Update Target URL

Endpoint: PUT https://api.dco.ink/api/links/:code Update the target URL of an existing short link.

Request Example (With Token):

curl -X PUT https://api.dco.ink/api/links/mybrand \
  -H "Authorization: Bearer dco_YOUR_TOKEN" \
  -d '{"url": "https://new-url.com"}'

Endpoint: DELETE https://api.dco.ink/api/links/:code Permanently destroy the specified short link.

Request Example (With Token):

curl -X DELETE https://api.dco.ink/api/links/mybrand \
  -H "Authorization: Bearer dco_YOUR_TOKEN"

Response Codes

  • 200/201: Request successful.
  • 400: Parameter error (e.g., invalid URL).
  • 401: Token missing or invalid.
  • 403: Insufficient permissions.
  • 429: Too many requests.