API Documentation

Integrate link shortening into your applications

Create Short Link

POST /api/v1/links

Creates a new shortened link from a long URL.

Request Headers

Content-Type: application/json

Request Body

{
  "url": "https://example.com/your/long/url"
}
Parameter Type Required Description
url string Yes The long URL to shorten (must be valid http/https URL)

Success Response

201 Created
{
  "id": 1,
  "short_url": "https://linkshor.tr/abc123",
  "long_url": "https://example.com/your/long/url"
}

Error Responses

400 Bad Request - Missing URL
{
  "error": "url is required"
}
422 Unprocessable Entity - Invalid URL
{
  "error": "url must be a valid URL (e.g., https://example.com)"
}

Example Usage

cURL

curl -X POST https://linkshor.tr/api/v1/links \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/very/long/url"}'

JavaScript (fetch)

const response = await fetch('https://linkshor.tr/api/v1/links', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://example.com/very/long/url'
  })
});

const data = await response.json();
console.log(data.short_url);

Python (requests)

import requests

response = requests.post(
    'https://linkshor.tr/api/v1/links',
    json={'url': 'https://example.com/very/long/url'}
)

data = response.json()
print(data['short_url'])