Skip to content

Latest commit

 

History

History
2580 lines (1896 loc) · 82.5 KB

api.rst

File metadata and controls

2580 lines (1896 loc) · 82.5 KB

single: REST single: API

Weblate's REST API

2.6

The REST API is available since Weblate 2.6.

The API is accessible on the /api/ URL and it is based on Django REST framework. You can use it directly or by wlc.

Authentication and generic parameters

The public project API is available without authentication, though unauthenticated requests are heavily throttled (by default to 100 requests per day), so it is recommended to use authentication. The authentication uses a token, which you can get in your profile. Use it in the Authorization header:

Authentication examples

Example request:

GET /api/ HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
Authorization: Token YOUR-TOKEN

Example response:

HTTP/1.0 200 OK
Date: Fri, 25 Mar 2016 09:46:12 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, HEAD, OPTIONS

{
    "projects":"http://example.com/api/projects/",
    "components":"http://example.com/api/components/",
    "translations":"http://example.com/api/translations/",
    "languages":"http://example.com/api/languages/"
}

CURL example:

curl \
    -H "Authorization: Token TOKEN" \
    https://example.com/api/

Passing Parameters Examples

For the :http:method:POST method the parameters can be specified either as form submission (application/x-www-form-urlencoded) or as JSON (application/json).

Form request example:

http

POST /api/projects/hello/repository/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/x-www-form-urlencoded Authorization: Token TOKEN

operation=pull

JSON request example:

http

POST /api/projects/hello/repository/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20

{"operation":"pull"}

CURL example:

curl \
    -d operation=pull \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/components/hello/weblate/repository/

CURL JSON example:

curl \
    --data-binary '{"operation":"pull"}' \
    -H "Content-Type: application/json" \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/components/hello/weblate/repository/

API rate limiting

The API requests are rate limited; the default configuration limits it to 100 requests per day for anonymous users and 5000 requests per hour for authenticated users.

Rate limiting can be adjusted in the settings.py; see Throttling in Django REST framework documentation for more details how to configure it.

The status of rate limiting is reported in following headers:

X-RateLimit-Limit Rate limiting limit of requests to perform
X-RateLimit-Remaining Remaining limit of requests
X-RateLimit-Reset Number of seconds until ratelimit window resets

4.1

Added ratelimiting status headers.

rate-limit, user-rate

API Entry Point

Users

4.0

Groups

4.0

Roles

Languages

Projects

Components

Translations

Units

A unit is a single piece of a translation which pairs a source string with a corresponding translated string and also contains some related metadata. The term is derived from the Translate Toolkit and XLIFF.

2.10

Changes

2.10

Screenshots

2.14

Addons

4.4.1

Component lists

4.0

Glossary

4.5

Glossaries are now stored as regular components, translations and strings, please use respective API instead.

Tasks

4.4

Notification hooks

Notification hooks allow external applications to notify Weblate that the VCS repository has been updated.

You can use repository endpoints for projects, components and translations to update individual repositories; see :http:post:/api/projects/(string:project)/repository/ for documentation.

Exports

Weblate provides various exports to allow you to further process the data.

RSS feeds

Changes in translations are exported in RSS feeds.