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 "X-API-Key: dco_YOUR_TOKEN" \
  -d '{"url": "https://example.com/very-long-url"}'

0. Quick Shorten (Simplified Plain Text API)

Endpoint: GET https://api.dco.ink/api/s

If you are writing a simple bash script, IoT device code, or just want the absolute easiest way to generate an anonymous short link without dealing with JSON, you can use our simplified GET endpoint.

ParameterTypeDescription
urlstring[Required] Target long URL (must be URL encoded).

Request Example:

curl -s "https://api.dco.ink/api/s?url=https://github.com"

Response: It returns the raw short URL as plain text, with no JSON parsing required.

https://dco.ink/x8kf2

(Note: If an error occurs, it returns a plain text error like error: invalid_url with a 400 status code).

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 "X-API-Key: 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 "X-API-Key: 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 "X-API-Key: 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 "X-API-Key: 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.