API Documentation

Создание короткой ссылки

POST /api/shorten

Создает новую короткую ссылку из полного URL.

Запрос

curl -X POST https://go.scidex.ru/api/shorten \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com"}'

Ответ

{
  "short_code": "abc12",
  "short_url": "https://go.scidex.ru/abc12",
  "original_url": "https://example.com"
}

Ошибки

  • 400 - URL не указан
  • 400 - Неверный формат URL
  • 400 - URL слишком длинный
  • 500 - Ошибка при создании короткой ссылки

Ограничения

  • Максимальная длина URL: 2048 символов
  • Длина короткого кода: 5 символов
  • Поддерживаемые протоколы: http, https
  • Нельзя создавать короткие ссылки на другие короткие ссылки

Примеры использования

JavaScript

const response = await fetch('https://go.scidex.ru/api/shorten', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    url: 'https://example.com'
  })
});

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

Python

import requests

response = requests.post(
    'https://go.scidex.ru/api/shorten',
    json={'url': 'https://example.com'}
)

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