single: REST single: 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
.
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:
4.10
Project scoped tokens were introduced in the 4.10 release.
Each user has his personal access token which can be obtained in the user profile. Newly generated user tokens have the wlu_
prefix.
It is possible to create project scoped tokens for API access to given project only. These tokens can be identified by the wlp_
prefix.
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/
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/
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.
In the Docker container this can be configured using WEBLATE_API_RATELIMIT_ANON
and WEBLATE_API_RATELIMIT_USER
.
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
, WEBLATE_API_RATELIMIT_ANON
, WEBLATE_API_RATELIMIT_USER
4.0
4.0
Hint
Use :http:post:/api/projects/(string:project)/components/ to create new components.
4.14
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
2.10
2.14
4.4.1
4.0
4.5
Glossaries are now stored as regular components, translations and strings, please use respective API instead.
4.4
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.
Weblate provides various exports to allow you to further process the data.
Changes in translations are exported in RSS feeds.