Divvun API

Documentation for the Divvun API endpoints

Introduction

Welcome to the Divvun API documentation. This API provides endpoints for interacting with the Divvun service.

Base URL

All API endpoints are relative to the base URL:

https://api.giellalt.org

Rate Limits

Requests are rate limited per client IP address, so that the service stays responsive for everyone. Each endpoint accepts a burst of requests at once, and the allowance then refills at its sustained rate. The limits reflect how expensive each kind of request is to process.

Endpoint Burst Sustained rate Maximum request body
/grammar/:tag 20 requests 10 requests per second 1 MiB
/speller/:tag 50 requests 25 requests per second 1 MiB
/tts/:tag/:voice 3 requests 12 requests per minute (one every 5 seconds) 64 KiB

Text-to-speech also limits how many requests are synthesized at once across all clients, so when it is busy a request can be refused even though you are within your own limit.

A request body larger than the endpoint's maximum is refused with 413 Request Entity Too Large. Send long texts in smaller pieces, such as a paragraph at a time.

Handling 429 Too Many Requests

A request that is refused for any of these reasons gets the status 429 Too Many Requests. Check its headers before sending another request:

  • Retry-After: the number of seconds to wait before sending another request. When it is present, always wait at least this long.
  • X-Retry-In: the same wait as a precise duration, such as 4.812s. It is sent when you have exceeded a rate limit.
  • Cs-Remediation: ban: your IP address has been blocked temporarily because its traffic looked abusive. Retry-After gives the time left on the block, which can be hours. Send no requests until it has passed.

A 429 without Retry-After, as when text-to-speech is busy, should be retried with an increasing delay, such as 1, 2, 4 and then 8 seconds.

Rate limit exceeded 429
HTTP/1.1 429 Too Many Requests
Retry-After: 5
X-Retry-In: 4.812s

Too Many Requests
IP address blocked 429
HTTP/1.1 429 Too Many Requests
Cs-Remediation: ban
Retry-After: 14102
Text-to-speech busy 429
HTTP/1.1 429 Too Many Requests

max connections reached: 2

Endpoints

Health Check

GET /health application/json

Check the health status of the API.

Response
{
    "status": "ok"
}

Grammar Check

POST /grammar/:tag application/json

Check grammar for text. Available languages:

  • fo - Føroyskt
  • se - Davvisámegiella
  • sma - Åarjelsaemien gïele
  • smj - Julevsámegiella
  • smn - Anarâškielâ
Request application/json
{
    "text": "sami"
}
Response application/json
{
  "text": "sami",
  "errs": [
    {
      "error_text": "sami",
      "start_index": 0,
      "end_index": 4,
      "error_code": "typo",
      "description": "Ii leat sátnelisttus",
      "suggestions": [
        "sámi"
      ],
      "title": "Čállinmeattáhus"
    }
  ]
}

Spell Check

POST /speller/:tag application/json

Check spelling for text. Available languages:

  • fo - Føroyskt
  • kl - Kalaallisut
  • se - Davvisámegiella
  • sma - Åarjelsaemien gïele
  • smj - Julevsámegiella
  • smn - Anarâškielâ
  • sms - Nuõrttsääʹmǩiõll
Request application/json
{
    "text": "sami"
}
Response application/json
{
  "text": "sami",
  "results": [
    {
      "word": "sami",
      "is_correct": false,
      "suggestions": [
        {
          "value": "sámi",
          "weight": 14.529631
        },
        {
          "value": "sama",
          "weight": 40.2973
        },
        {
          "value": "sáme",
          "weight": 45.896103
        },
        {
          "value": "sabmi",
          "weight": 50.2973
        },
        {
          "value": "samai",
          "weight": 50.2973
        },
        {
          "value": "sapmi",
          "weight": 50.2973
        },
        {
          "value": "satmi",
          "weight": 50.2973
        },
        {
          "value": "samo",
          "weight": 55.2973
        },
        {
          "value": "samu",
          "weight": 55.2973
        },
        {
          "value": "somá",
          "weight": 56.623154
        }
      ]
    }
  ]
}

Text-to-Speech

POST /tts/:tag/:voice audio/wav

MP3: add Accept: audio/mpeg header to get MP3 audio instead of WAV.

Convert text to speech. Available languages and voices:

Request application/json
{
    "text": "Sample text to convert to speech"
}
Response audio/wav

WAV audio file containing the synthesized speech.

Response audio/mpeg

MP3 audio file containing the synthesized speech (if Accept: audio/mpeg header provided)