Shorten a URL and get back a short lyng.my.id link.
This is the main thing the API does. You give it a long URL and it gives you back a short one. You send a POST request (meaning you're sending data, not just asking for it) to the /links endpoint.
/linksYou send a JSON object in the body of your request. JSON is just a structured way of writing data. Think of it like filling out a form with labelled fields.
urlstringrequiredThe long URL you want to shorten. Must start with http:// or https://. You cannot shorten a link that already points to lyng.my.id.
slugstringoptionalA custom ending for your short link. For example, if you set this to my-link, your short URL will be lyng.my.id/my-link. Only letters, numbers, and hyphens are allowed. Requires a Premium account.
If the request succeeds, lyng responds with status 201 Created and a JSON object containing your new short link.
shortUrlstringThe complete short URL, ready to share. Anyone who visits this link will be redirected to your original URL.
slugstringThe unique code at the end of the short URL (e.g. abc123).
Shorten a URL (terminal / curl)
curl -X POST https://lyng.my.id/api/v1/links \
-H "Authorization: Bearer lk_your_key" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'With a custom slug (Premium)
curl -X POST https://lyng.my.id/api/v1/links \
-H "Authorization: Bearer lk_your_key" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "slug": "my-link"}'Successful response
{
"shortUrl": "https://lyng.my.id/abc123",
"slug": "abc123"
}429 error until you upgrade to Premium or delete some links.slug field) are only available on Premium accounts.http:// or https://. Other protocols like ftp:// are not allowed.Content-Type: application/json. This tells lyng "I'm sending you JSON data". Without it, lyng won't be able to read what you sent and will return an error.