API reference

YakLink API documentation

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.

Endpoint

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.

Authentication

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.

Query parameters

ParameterRequiredDescription
apiKeyYesAPI key issued by YakLink.
urlYesThe long destination URL to shorten (must be a valid http/https URL).
domainNoDomain for the short link. Defaults to yak.link (yakl.ink also available). To use a custom domain it must be verified on your account.
slugNoCustom slug (letters, digits, hyphens, underscores). If omitted, an 8-character slug is generated. Must be unique for the domain.

Code samples

cURL

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"

JavaScript (fetch)

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);

Python (requests)

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

<?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"];

Go

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"])

Ruby

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"]

Response

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"
}
FieldTypeDescription
okbooleanTrue when the link was created.
short_urlstringThe full short link, ready to share.
slugstringThe slug (path component) of the short link.
domainstringThe domain the link was created on.
long_urlstringThe destination URL that was shortened.

Redirects

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

Errors return a non-200 status with a JSON body of the form { "ok": false, "error": "code", "message": "..." }.

StatuserrorMeaning
401missing_api_keyThe apiKey parameter was not supplied.
402invalid_api_keyAPI key is invalid or has reached its monthly request limit.
400missing_url / invalid_urlThe url parameter is missing or not a valid URL.
400invalid_slugThe slug contains characters other than letters, digits, hyphens, and underscores.
409slug_takenThe requested slug is already in use on that domain.
422domain_not_foundThe custom domain is not verified for your account.
500db_errorAn unexpected server error occurred.

Usage, plans & quotas

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.

PlanLinks / monthPrice
Free trial1030 days, no card required
Basic500$10 / month
Advanced2,500$50 / month
Enterprise10,000$100 / month

A machine-readable OpenAPI spec is available at https://yaklinks.com/openapi.yaml for use with code generators and API tooling.