A simple REST API to create short links programmatically. Every account gets an API key and a monthly quota that matches its plan. The full machine-readable spec is available as OpenAPI (openapi.yaml).
New here? Start with Getting Started, follow a how-to guide, or skim the FAQ.
POST https://yaklinks.com/v1/shorten
Parameters may be sent as a query string or as a form-encoded body. GET is also accepted for quick testing.
Every request requires an apiKey parameter. Create and manage keys on the API Keys page. Keep secret keys on your server. Your monthly request quota is determined by your plan — see Pricing.
| Parameter | Required | Description |
|---|---|---|
apiKey | Yes | API key issued by YakLink. |
url | Yes | The long destination URL to shorten (must be a valid http/https URL). |
domain | No | Domain for the short link. Defaults to yak.link (yakl.ink also available). To use a custom domain it must be verified on your account. |
slug | No | Custom slug (letters, digits, hyphens, underscores). If omitted, an 8-character slug is generated. Must be unique for the domain. |
curl -X POST "https://yaklinks.com/v1/shorten" \
--data-urlencode "apiKey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com/very/long/path" \
--data-urlencode "slug=spring-sale"
const body = new URLSearchParams({
apiKey: "YOUR_API_KEY",
url: "https://example.com/very/long/path",
});
const res = await fetch("https://yaklinks.com/v1/shorten", {
method: "POST",
body,
});
const data = await res.json();
console.log(data.short_url);
import requests
r = requests.post("https://yaklinks.com/v1/shorten", data={
"apiKey": "YOUR_API_KEY",
"url": "https://example.com/very/long/path",
})
print(r.json()["short_url"])
<?php
$body = http_build_query([
"apiKey" => "YOUR_API_KEY",
"url" => "https://example.com/very/long/path",
]);
$ctx = stream_context_create(["http" => [
"method" => "POST",
"header" => "Content-Type: application/x-www-form-urlencoded",
"content" => $body,
]]);
$res = json_decode(file_get_contents("https://yaklinks.com/v1/shorten", false, $ctx), true);
echo $res["short_url"];
form := url.Values{}
form.Set("apiKey", "YOUR_API_KEY")
form.Set("url", "https://example.com/very/long/path")
resp, _ := http.PostForm("https://yaklinks.com/v1/shorten", form)
defer resp.Body.Close()
var out map[string]interface{}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out["short_url"])
require "net/http"; require "json"; require "uri"
res = Net::HTTP.post_form(
URI("https://yaklinks.com/v1/shorten"),
"apiKey" => "YOUR_API_KEY",
"url" => "https://example.com/very/long/path")
puts JSON.parse(res.body)["short_url"]
A successful request returns 200 with the created link:
{
"ok": true,
"short_url": "https://yak.link/aB3xK7",
"slug": "aB3xK7",
"domain": "yak.link",
"long_url": "https://example.com/very/long/path"
}
| Field | Type | Description |
|---|---|---|
ok | boolean | True when the link was created. |
short_url | string | The full short link, ready to share. |
slug | string | The slug (path component) of the short link. |
domain | string | The domain the link was created on. |
long_url | string | The destination URL that was shortened. |
Visiting a short link issues an HTTP redirect to the destination and records a click for your analytics:
GET https://yak.link/aB3xK7 → 302 Found (Location: long_url)
Errors return a non-200 status with a JSON body of the form { "ok": false, "error": "code", "message": "..." }.
| Status | error | Meaning |
|---|---|---|
401 | missing_api_key | The apiKey parameter was not supplied. |
402 | invalid_api_key | API key is invalid or has reached its monthly request limit. |
400 | missing_url / invalid_url | The url parameter is missing or not a valid URL. |
400 | invalid_slug | The slug contains characters other than letters, digits, hyphens, and underscores. |
409 | slug_taken | The requested slug is already in use on that domain. |
422 | domain_not_found | The custom domain is not verified for your account. |
500 | db_error | An unexpected server error occurred. |
Each plan includes a monthly allowance of created links; one /v1/shorten call counts as one. Redirects (clicks) are unlimited and never count against your quota. Your remaining allowance is shown on the API Keys page, and you can change plans on the Account & Billing page.
| Plan | Links / month | Price |
|---|---|---|
| Free trial | 10 | 30 days, no card required |
| Basic | 500 | $10 / month |
| Advanced | 2,500 | $50 / month |
| Enterprise | 10,000 | $100 / month |
A machine-readable OpenAPI spec is available at https://yaklinks.com/openapi.yaml for use with code generators and API tooling.