amaGama API

amaGama answers HTTP requests with JSON. The API lives under /api/v1/; /tmserver/ is the older path to the same read API and still works.

TM suggestion request

Request TM suggestions with a GET of <SERVER>/api/v1/<SOURCE_LANGUAGE>/<TARGET_LANGUAGE>/unit/<QUERY>, where:

Placeholder

Description

<SERVER>

The URL of the amaGama server

<SOURCE_LANGUAGE>

Source language code: de, en, en_GB

<TARGET_LANGUAGE>

Target language: ar, es_AR, fr, hi

<QUERY>

The URL escaped string to be queried

Note

<SOURCE_LANGUAGE> and <TARGET_LANGUAGE> should be language codes in the form of LANG OR LANG_COUNTRY. LANG should be a language code from ISO 639 and COUNTRY a country code from ISO 3166. The following are valid examples: ar, de, en, en_GB, es_AR, fr, gl, hi, tlh,… For the public server the code en is used for the source language for most of the FOSS localization files, not en_US.

For example:

https://amagama-live.translatehouse.org/api/v1/en/af/unit/Computer

The string can also be passed as source in the query string, which avoids problems with / in the string on some web servers:

https://amagama-live.translatehouse.org/api/v1/en/af/unit/?source=Open%2FSave

Providing options

It is possible to provide some options in the request URL by using a query string with one or more of the following fields.

Option

Description

min_similarity

The minimum similarity between the string to be searched and the strings to match. See Levenshtein distance. Values below 70 are raised to 70. Default: MIN_SIMILARITY (70).

max_candidates

The maximum number of results, at most 30. Default: MAX_CANDIDATES (5).

style

The project’s checker style, so that accelerators and similar markup are matched as that project writes them (& for KDE, _ for GNOME). One of: creativecommons, drupal, gnome, ios, kde, libreoffice, minimal, mozilla, openoffice, reduced, standard, terminology, wx.

exclude

Comma-separated globs of block names to leave out, such as hosted-*. A suggestion stays while any of its sources is left.

only

Comma-separated globs of the block names to keep, such as gnome-*,kde. Suggestions with no recorded source are left out.

weight

Comma-separated glob:weight pairs, weights from 0 to 10, such as gnome-*:1.5,hosted-*:0.5. Suggestions are ordered by quality times the best weight of their sources: each source’s first matching glob, else the block’s default weight in the sources list. quality itself isn’t changed.

licence

Comma-separated globs of the SPDX licence identifiers to keep, such as GPL-*,MIT, or with ! to leave out, such as !AGPL-*: see Choosing by licence.

exclude_checks

Comma-separated globs of check names: suggestions flagged with a matching checks name are left out, such as accelerators,variables; * leaves out every flagged suggestion.

jsoncallback

Wrap the reply in a call to this JavaScript function (JSONP), served as text/javascript. An ASCII name such as f or app.f; any other value is ignored.

The source options are applied before max_candidates, and a suggestion’s sources lists only the sources it keeps. Of equally good suggestions, the one more of its kept sources supplied comes first.

For example:

https://amagama-live.translatehouse.org/api/v1/en/af/unit/File?style=gnome&max_candidates=10
https://amagama-live.translatehouse.org/api/v1/en/af/unit/File?exclude=hosted-*&weight=gnome-*:1.5

Choosing by licence

licence lists the licences a client can use its suggestions under, as globs of SPDX identifiers (case doesn’t matter). Each source’s licence is an SPDX expression, and a source is kept when the expression can be met with the listed licences alone:

  • A OR B lets you choose either licence, so one of them listed is enough.

  • A AND B applies both licences, so both must be listed.

  • A WITH exception only adds permissions to A, so A listed is enough.

With licence=GPL-*,MIT:

Source’s licence

Kept

Because

GPL-2.0-or-later

yes

GPL-* matches it

LGPL-2.1-or-later

no

a glob matches the whole identifier: GPL-* isn’t LGPL

LGPL-2.1-or-later OR GPL-3.0-only

yes

you can use it under GPL-3.0-only

MIT AND Apache-2.0

no

Apache-2.0 also applies, and isn’t listed

MIT AND (Apache-2.0 OR GPL-2.0-only)

yes

MIT, and GPL-2.0-only for the choice

GPL-2.0-or-later WITH Classpath-exception-2.0

yes

GPL-* matches the licence

A glob starting with ! leaves licences out: a licence is allowed when it matches a listed glob and no ! one. With only ! globs, every other licence is allowed. With licence=!AGPL-*:

Source’s licence

Kept

Because

MIT

yes

every licence but AGPL is allowed

AGPL-3.0-only

no

AGPL-* is left out

MIT OR AGPL-3.0-only

yes

you can use it under MIT

MIT AND AGPL-3.0-only

no

AGPL-3.0-only also applies

licence=GPL-*,!GPL-3.0-* keeps GPL-2.0-only but not GPL-3.0-only.

Sources with no known licence, or files under different licences, are left out. A suggestion stays while any of its sources is kept, as with only.

A request returns 404 if the source language isn’t in the database or if no string is given. It returns 400 if the source and target languages are the same (en_US is the same as en, en_GB isn’t) or if a weight isn’t glob:weight. Replies may be cached for an hour (Cache-Control: max-age=3600, public).

Prefetch and bulk requests

A client asking ahead of need says so with a Sec-Purpose header: prefetch for a lookup it expects to need soon (the next units), prefetch;bulk for one of many fetched together (a whole file, to work offline). Ordinary lookups send neither. Prefetches are answered like ordinary lookups. The public server limits bulk requests from each client, and in total, so they can’t crowd out people translating now: one over the limit gets a 429 with Retry-After, and the client should wait that many seconds before its next bulk request. Other lookups have a separate, higher limit for each client, well above what someone translating sends; one over it gets a 429 with Retry-After too.

TM suggestion results

The results from a TM suggestion request are provided in JSON format. It is a list containing zero or more results. The results contain the following fields:

Field

Description

source

Matching unit’s source language text

target

Matching unit’s target language text

quality

A Levenshtein distance measure of quality as percent

rank

An internal quantity that might disappear. Ignore.

sources

The blocks whose imports supplied this translation, in alphabetical order: api for the write API. Empty if none was recorded.

checks

The names of the checks this translation fails, in the order the rebuild ran them, such as ["endpunc"]: maybe broken, maybe only styled differently. Empty if it fails none, or wasn’t checked (added since the last rebuild).

An example:

[
  {
    "source": "Computer",
    "quality": 100.0,
    "target": "Rekenaar",
    "rank": 100.0,
    "sources": ["gnome-51", "kde"],
    "checks": []
  },
  {
    "source": "Computers",
     "quality": 88.888888888888886,
     "target": "Rekenaars",
     "rank": 100.0,
     "sources": ["kde"],
     "checks": []
   },
   {
     "source": "&Computer",
     "quality": 88.888888888888886,
     "target": "Rekenaar",
     "rank": 100.0,
     "sources": ["kde"],
     "checks": ["accelerators"]
   },
   {
     "source": "_Computer",
     "quality": 88.888888888888886,
     "target": "_Rekenaar",
     "rank": 100.0,
     "sources": ["gnome-51"],
     "checks": []
   },
   {
     "source": "My Computer",
     "quality": 72.727272727272734,
     "target": "My Rekenaar",
     "rank": 100.0,
     "sources": ["legacy-2019"],
     "checks": []
   }
 ]

Available languages

GET <SERVER>/api/v1/languages/ lists the languages in the database:

{
  "sourceLanguages": ["en"],
  "targetLanguages": ["af", "ar", "de"]
}

Sources

GET <SERVER>/api/v1/sources/ lists the blocks the translations were imported from, one entry per block and source language. The names are those suggestions give in sources. Titles are in the language ?lang= asks for, or else the best of Accept-Language, among the translated ones; otherwise English. The reply gives that language as lang and its text direction (ltr or rtl) as dir.

Field

Description

name

The block’s name

title

Its title, or its name if it has none

version

Its release, such as "51", or null

displayTitle

The title with its release, worded for the language

licence

Its SPDX licence expression, or null

sourceLanguage

The source language

targetLanguages

The target languages it was imported for

units

How many units its files gave, before those already there from other files were merged

imported

When it was last imported, in UTC

weight

Its default weight in lookups: 1 unless the server sets one

{
  "lang": "en",
  "dir": "ltr",
  "sources": [
    {
      "name": "gnome-51",
      "title": "GNOME",
      "version": "51",
      "displayTitle": "GNOME 51",
      "licence": "GPL-2.0-or-later",
      "sourceLanguage": "en",
      "targetLanguages": ["af", "ar", "de"],
      "units": 5000,
      "weight": 1.0,
      "imported": "2026-10-25T12:00:00Z"
    }
  ]
}

Statistics

GET <SERVER>/api/v1/stats/ returns the figures of the statistics page (/stats/), as update_stats last computed them; until it has, the reply is a 404 with an error. Times are in UTC.

Field

Description

version

The format’s version, 1

computed

When the translation figures were last computed

sourceLanguages

The figures of each source language, by code

use

The lookups per day, or null

Each source language has:

Field

Description

built

When the data was rebuilt (its last import)

sources

Source strings

words

Their words

targets

Translations

languages

Per target language: code, targets, sources (the source strings it translates), words (theirs), coverage (sources as a share of all, 0 to 1) and checks (failures by check)

blocks

Per block: name, title, version, languages (how many), targets (null for data built before translations recorded their imports), imported and checks

checks

flagged: the checks that flag translations; failures: each one’s failures; leftOutChecks: the checks whose failures rebuilds leave out; leftOut: what the last rebuild left out (targets, and checks by check), or null if unknown; categories: each check’s category, as translate-toolkit’s critical, functional, cosmetic or extraction

history

built, sources, words, targets and languages (how many) at each of the last 52 rebuilds, oldest first

computed

When these figures were computed

use has computed and days: per day (in the server’s time zone), date and the lookups by kind, ordinary, prefetch and bulk (see Sec-Purpose), with limited, how many of them were refused with a 429. They are totals only.

{
  "version": 1,
  "computed": "2026-11-01T18:00:00Z",
  "sourceLanguages": {
    "en": {
      "built": "2026-11-01T12:00:00.000000Z",
      "computed": "2026-11-01T18:00:00Z",
      "sources": 1000,
      "words": 5000,
      "targets": 2000,
      "languages": [
        {"code": "af", "targets": 2000, "sources": 900, "words": 4000,
         "coverage": 0.9, "checks": {"tags": 10}}
      ],
      "blocks": [
        {"name": "gnome-51", "title": "GNOME", "version": "51", "languages": 1,
         "targets": 2000, "imported": "2026-11-01T12:00:00Z",
         "checks": {"tags": 10}}
      ],
      "checks": {
        "flagged": ["tags"],
        "failures": {"tags": 10},
        "leftOutChecks": ["printf", "braces", "script"],
        "leftOut": {"targets": 5, "checks": {"printf": 5, "braces": 0, "script": 0}},
        "categories": {"tags": "critical", "printf": "critical", "braces": "critical",
                       "script": "critical"}
      },
      "history": [
        {"built": "2026-11-01T12:00:00.000000Z", "sources": 1000, "words": 5000,
         "targets": 2000, "languages": 1}
      ]
    }
  },
  "use": {
    "computed": "2026-11-02T00:30:00Z",
    "days": [
      {"date": "2026-11-01", "ordinary": 1000, "prefetch": 500, "bulk": 100,
       "limited": 0}
    ]
  }
}

Adding translations

When ENABLE_DATA_ALTERING_API is on (it is off by default), the API also accepts translations. style can be passed as for lookups.

Method

Path

Body

PUT or POST

/api/v1/<SRC>/<TGT>/unit/<QUERY>

JSON object with source and target

POST

/api/v1/<SRC>/<TGT>/store/<NAME>

JSON list of objects with source and target

PUT

/api/v1/<SRC>/<TGT>/store/<NAME>

A translation file; its format is taken from <NAME>

The store requests reply added <N> units from <NAME>. A request with a language code that isn’t valid, a body not shaped as above, or a file that can’t be read returns 400. Strings too long for the database’s index are skipped. Each request is recorded as an import of block api, named unit or <NAME>.