Weblate 的 REST API

API 可以在 /api/ URL上存取,並且它基於 Django REST framework。您可以直接使用或參考 Weblate 客戶端

身份驗證和通用參數

公開專案 API 不需要身份驗證就可用,儘管沒有身份驗證的請求導致嚴重的瓶頸(預設每天 100 個請求),所以推薦使用身份驗證。身份驗證使用令牌,這可以在您的簡介中得到。在 Authorization 標頭中使用它:

ANY /

對於 API的普通請求行為,標頭、狀態編碼和參數在這裡也應用於所有端點。

查詢參數:
  • format – 響應格式(覆蓋了 Accept)。可能的值相依於 REST 框架設定,預設支援 jsonapi。後者為 API 提供了 web 瀏覽器接口。

  • page – Returns given page of paginated results (use next and previous fields in response to automate the navigation).

  • page_size – Return the given number of items per request. The default is 50 and the maximum is 1000. For the units endpoints the default is 100 with a maximum of 10000. The default value is also configurable using the PAGE_SIZE setting.

請求標頭:
  • Accept – 相應內容的類型相依於 Accept 標頭

  • Authorization – optional token to authenticate as Authorization: Token YOUR-TOKEN

響應標頭:
Response JSON Object:
  • detail (string) – 結果的詳細描述(對於 200 OK 以外的 HTTP 狀態編碼)

  • count (int) – 對象列表的總項目計數

  • next (string) – 對象列表的下一頁 URL

  • previous (string) – 對象列表的上一頁 URL

  • results (array) – 對象列表的結果

  • url (string) – 使用 API 存取這個資源的 URL

  • web_url (string) – 使用瀏覽器存取這個資源的 URL

狀態編碼:

Authentication tokens

在 4.10 版的變更: Project scoped tokens were introduced in the 4.10 release.

Each user has a 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.

身份驗證的例子

示例請求:

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

示例響應:

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 示例:

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

Passing Parameters Examples

對於 POST 方法,參數可以指定為表格送交(application/x-www-form-urlencoded)或 JSON (application/json)。

Form request example:

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:

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 示例:

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/

Components and categories

To access a component which is nested inside a 類別, you need to URL encode the category name into a component name separated with a slash. For example usage placed in a docs category needs to be used as docs%252Fusage. Full URL in this case would be for example https://example.com/api/components/hello/docs%252Fusage/repository/.

API 頻次限制

這個 API 請求限制了速率;對於匿名使用者預設組態限制為每天 100 個請求,對於身份驗證的使用者限制為每小時 5000 個請求。

速率限制可以在:file:settings.py 中調整;如何組態它的更多細節請參見`Throttling in Django REST framework documentation <https://www.django-rest-framework.org/api-guide/ throttling/>`_。

In the Docker container this can be configured using WEBLATE_API_RATELIMIT_ANON and WEBLATE_API_RATELIMIT_USER.

速率限制在後面的標頭中報告:

X-RateLimit-Limit

要執行的對速率限制進行限制的請求

X-RateLimit-Remaining

保持限制的請求

X-RateLimit-Reset

直到速率限制窗口重置時的秒數

在 4.1 版的變更: 新增速率限制狀態的標頭。

API 入口點

GET /api/

API 根入口點。

示例請求:

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

示例響應:

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/"
}

使用者

Added in version 4.0.

GET /api/users/

返回使用者列表,如果有權限查看管理使用者的話。如果沒有,那麼會只看到自己的具體資訊。

也參考

使用者對象屬性被歸檔在 GET /api/users/(str:username)/

POST /api/users/

建立新使用者。

參數值:
  • username (string) – 使用者名稱

  • full_name (string) – User full name

  • email (string) – 使用者電子郵箱

  • is_superuser (boolean) – 使用者是超級使用者嗎? (可選的)

  • is_active (boolean) – 使用者是活動使用者嗎? (可選的)

  • is_bot (boolean) – Is user bot? (optional) (used for project scoped tokens)

GET /api/users/(str: username)/

返回使用者的資訊。

參數值:
  • username (string) – 使用者的使用者名

Response JSON Object:
  • username (string) – 使用者的使用者名

  • full_name (string) – 使用者的全名

  • email (string) – 使用者的電子郵箱

  • is_superuser (boolean) – 使用者是否是超級使用者

  • is_active (boolean) – 使用者是否是活動使用者

  • is_bot (boolean) – whether the user is bot (used for project scoped tokens)

  • date_joined (string) – 建立使用者的日期

  • last_login (string) – date the user last signed in

  • groups (array) – 連接到關聯的組;請參見 GET /api/groups/(int:id)/

Example JSON data:

{
    "email": "user@example.com",
    "full_name": "Example User",
    "username": "exampleusername",
    "groups": [
        "http://example.com/api/groups/2/",
        "http://example.com/api/groups/3/"
    ],
    "is_superuser": true,
    "is_active": true,
    "is_bot": false,
    "date_joined": "2020-03-29T18:42:42.617681Z",
    "url": "http://example.com/api/users/exampleusername/",
    "statistics_url": "http://example.com/api/users/exampleusername/statistics/"
}
PUT /api/users/(str: username)/

更改使用者參數。

參數值:
  • username (string) – 使用者的使用者名

Response JSON Object:
  • username (string) – 使用者的使用者名

  • full_name (string) – 使用者的全名

  • email (string) – 使用者的電子郵箱

  • is_superuser (boolean) – 使用者是否是超級使用者

  • is_active (boolean) – 使用者是否是活動使用者

  • is_bot (boolean) – whether the user is bot (used for project scoped tokens)

  • date_joined (string) – 建立使用者的日期

PATCH /api/users/(str: username)/

更改使用者參數。

參數值:
  • username (string) – 使用者的使用者名

Response JSON Object:
  • username (string) – 使用者的使用者名

  • full_name (string) – 使用者的全名

  • email (string) – 使用者的電子郵箱

  • is_superuser (boolean) – 使用者是否是超級使用者

  • is_active (boolean) – 使用者是否是活動使用者

  • is_bot (boolean) – whether the user is bot (used for project scoped tokens)

  • date_joined (string) – 建立使用者的日期

DELETE /api/users/(str: username)/

刪除所有的使用者資訊並將使用者標記為不活動使用者。

參數值:
  • username (string) – 使用者的使用者名

POST /api/users/(str: username)/groups/

將群組與使用者關聯。

參數值:
  • username (string) – 使用者的使用者名

表格參數:
  • string group_id – 唯一的群組 ID

DELETE /api/users/(str: username)/groups/

Added in version 4.13.1.

Remove user from a group.

參數值:
  • username (string) – 使用者的使用者名

表格參數:
  • string group_id – 唯一的群組 ID

GET /api/users/(str: username)/statistics/

使用者的統計資料列表。

參數值:
  • username (string) – 使用者的使用者名

Response JSON Object:
  • translated (int) – Number of translations by user

  • suggested (int) – Number of suggestions by user

  • uploaded (int) – Number of uploads by user

  • commented (int) – Number of comments by user

  • languages (int) – Number of languages user can translate

GET /api/users/(str: username)/notifications/

使用者的訂閱列表。

參數值:
  • username (string) – 使用者的使用者名

POST /api/users/(str: username)/notifications/

將訂閱與使用者關聯。

參數值:
  • username (string) – 使用者的使用者名

Request JSON Object:
  • notification (string) – 註冊通知的名稱

  • scope (int) – 來自可用選擇的通知範圍

  • frequency (int) – 通知的頻率選擇

GET /api/users/(str: username)/notifications/(int: subscription_id)/

獲得與使用者關聯的訂閱。

參數值:
  • username (string) – 使用者的使用者名

  • subscription_id (int) – ID of notification registered

PUT /api/users/(str: username)/notifications/(int: subscription_id)/

編輯與使用者關聯的訂閱。

參數值:
  • username (string) – 使用者的使用者名

  • subscription_id (int) – ID of notification registered

Request JSON Object:
  • notification (string) – 註冊通知的名稱

  • scope (int) – 來自可用選擇的通知範圍

  • frequency (int) – 通知的頻率選擇

PATCH /api/users/(str: username)/notifications/(int: subscription_id)/

編輯與使用者關聯的訂閱。

參數值:
  • username (string) – 使用者的使用者名

  • subscription_id (int) – ID of notification registered

Request JSON Object:
  • notification (string) – 註冊通知的名稱

  • scope (int) – 來自可用選擇的通知範圍

  • frequency (int) – 通知的頻率選擇

DELETE /api/users/(str: username)/notifications/(int: subscription_id)/

刪除與使用者關聯的訂閱。

參數值:
  • username (string) – 使用者的使用者名

  • subscription_id – 註冊通知的名稱

  • subscription_id – int

群組

Added in version 4.0.

GET /api/groups/

返回群組列表,如果有權限看到管理群組的話,如果沒有,那麼會只看到使用者所在的群組。

也參考

群組對象屬性歸檔在 GET /api/groups/(int:id)/

POST /api/groups/

建立新的群組。

參數值:
GET /api/groups/(int: id)/

返回群組的資訊。

參數值:
  • id (int) – 群組的 ID

Response JSON Object:

Example JSON data:

{
    "name": "Guests",
    "defining_project": null,
    "project_selection": 3,
    "language_selection": 1,
    "url": "http://example.com/api/groups/1/",
    "roles": [
        "http://example.com/api/roles/1/",
        "http://example.com/api/roles/2/"
    ],
    "languages": [
        "http://example.com/api/languages/en/",
        "http://example.com/api/languages/cs/",
    ],
    "projects": [
        "http://example.com/api/projects/demo1/",
        "http://example.com/api/projects/demo/"
    ],
    "componentlist": "http://example.com/api/component-lists/new/",
    "components": [
        "http://example.com/api/components/demo/weblate/"
    ]
}
PUT /api/groups/(int: id)/

更改群組參數。

參數值:
  • id (int) – 群組的 ID

Response JSON Object:
  • name (string) – 群組的名稱

  • project_selection (int) – 相應於對象群組的整數

  • language_selection (int) – 相應於語言群組的整數

PATCH /api/groups/(int: id)/

更改群組參數。

參數值:
  • id (int) – 群組的 ID

Response JSON Object:
  • name (string) – 群組的名稱

  • project_selection (int) – 相應於對象群組的整數

  • language_selection (int) – 相應於語言群組的整數

DELETE /api/groups/(int: id)/

Deletes the group.

參數值:
  • id (int) – 群組的 ID

POST /api/groups/(int: id)/roles/

將角色與群組關聯。

參數值:
  • id (int) – 群組的 ID

表格參數:
  • string role_id – 唯一的角色 ID

POST /api/groups/(int: id)/components/

將組件與群組關聯。

參數值:
  • id (int) – 群組的 ID

表格參數:
  • string component_id – 唯一的組件 ID

DELETE /api/groups/(int: id)/components/(int: component_id)

從群組刪除組件。

參數值:
  • id (int) – 群組的 ID

  • component_id (int) – 唯一的組件 ID

POST /api/groups/(int: id)/projects/

將項目與群組關聯。

參數值:
  • id (int) – 群組的 ID

表格參數:
  • string project_id – 唯一的項目 ID

DELETE /api/groups/(int: id)/projects/(int: project_id)

從群組刪除項目。

參數值:
  • id (int) – 群組的 ID

  • project_id (int) – 唯一的項目 ID

POST /api/groups/(int: id)/languages/

將語言與群組關聯。

參數值:
  • id (int) – 群組的 ID

表格參數:
  • string language_code – 唯一的語言代碼

DELETE /api/groups/(int: id)/languages/(string: language_code)

從群組刪除語言。

參數值:
  • id (int) – 群組的 ID

  • language_code (string) – 唯一的語言代碼

POST /api/groups/(int: id)/componentlists/

將組件列表與群組關聯。

參數值:
  • id (int) – 群組的 ID

表格參數:
  • string component_list_id – 唯一的組件列表 ID

DELETE /api/groups/(int: id)/componentlists/(int: component_list_id)

從群組刪除組件列表。

參數值:
  • id (int) – 群組的 ID

  • component_list_id (int) – 唯一的組件列表 ID

POST /api/groups/(int: id)/admins/

Added in version 5.5.

Add user to team admins.

參數值:
  • id (int) – 群組的 ID

表格參數:
  • string user_id – The user’s ID

DELETE /api/groups/(int: id)/admins/(int: user_id)

Added in version 5.5.

Delete user from team admins.

參數值:
  • id (int) – 群組的 ID

  • user_id (integer) – The user’s ID

角色

GET /api/roles/

返回與使用者關聯的所有角色列表。如果使用者是超級使用者,那麼返回所有現有角色的列表。

也參考

角色對象屬性歸檔在 GET /api/roles/(int:id)/

POST /api/roles/

建立新角色。

參數值:
  • name (string) – 角色名稱

  • permissions (array) – 權限編碼名稱的列表

GET /api/roles/(int: id)/

返回角色的資訊。

參數值:
  • id (int) – 角色 ID

Response JSON Object:
  • name (string) – 角色名稱

  • permissions (array) – 權限編碼名稱的列表

Example JSON data:

{
    "name": "Access repository",
    "permissions": [
        "vcs.access",
        "vcs.view"
    ],
    "url": "http://example.com/api/roles/1/",
}
PUT /api/roles/(int: id)/

更改角色參數。

參數值:
  • id (int) – 角色的ID

Response JSON Object:
  • name (string) – 角色名稱

  • permissions (array) – 權限編碼名稱的列表

PATCH /api/roles/(int: id)/

更改角色參數。

參數值:
  • id (int) – 角色的ID

Response JSON Object:
  • name (string) – 角色名稱

  • permissions (array) – 權限編碼名稱的列表

DELETE /api/roles/(int: id)/

Deletes the role.

參數值:
  • id (int) – 角色的ID

語言

GET /api/languages/

返回所有語言的列表。

也參考

語言對象屬性存檔在 GET /api/languages/(string:language)/

POST /api/languages/

建立新的語言。

參數值:
  • code (string) – 語言名稱

  • name (string) – 語言名稱

  • direction (string) – 文字方向

  • population (int) – 語言使用者數量

  • plural (object) – 語言複數形式與數字

GET /api/languages/(string: language)/

返回語言的資訊。

參數值:
  • language (string) – 語言碼

Response JSON Object:
  • code (string) – 語言碼

  • direction (string) – 文字方向

  • plural (object) – 語言複數資訊的對象

  • aliases (array) – 語言別名的數組

Request JSON Object:
  • population (int) – 語言使用者數量

Example JSON data:

{
    "code": "en",
    "direction": "ltr",
    "name": "English",
    "population": 159034349015,
    "plural": {
        "id": 75,
        "source": 0,
        "number": 2,
        "formula": "n != 1",
        "type": 1
    },
    "aliases": [
        "english",
        "en_en",
        "base",
        "source",
        "eng"
    ],
    "url": "http://example.com/api/languages/en/",
    "web_url": "http://example.com/languages/en/",
    "statistics_url": "http://example.com/api/languages/en/statistics/"
}
PUT /api/languages/(string: language)/

更改語言參數。

參數值:
  • language (string) – 語言的編碼

Request JSON Object:
  • name (string) – 語言名稱

  • direction (string) – 文字方向

  • population (int) – 語言使用者數量

  • plural (object) – Language plural details

PATCH /api/languages/(string: language)/

更改語言參數。

參數值:
  • language (string) – 語言的編碼

Request JSON Object:
  • name (string) – 語言名稱

  • direction (string) – 文字方向

  • population (int) – 語言使用者數量

  • plural (object) – Language plural details

DELETE /api/languages/(string: language)/

Deletes the language.

參數值:
  • language (string) – 語言的編碼

GET /api/languages/(string: language)/statistics/

返回語言的統計資料。

參數值:
  • language (string) – 語言碼

也參考

Returned attributes are described in 統計數據.

專案

GET /api/projects/

返回所有項目的列表。

也參考

項目對象的屬性存檔在 GET /api/projects/(string:project)/

POST /api/projects/

建立新項目。

參數值:
  • name (string) – 專案名稱

  • slug (string) – 項目標識串

  • web (string) – 專案網站

GET /api/projects/(string: project)/

返回項目的資訊。

參數值:
  • project (string) – 專案 URL slug

Response JSON Object:

Example JSON data:

{
    "name": "Hello",
    "slug": "hello",
    "url": "http://example.com/api/projects/hello/",
    "web": "https://weblate.org/",
    "web_url": "http://example.com/projects/hello/"
}
PATCH /api/projects/(string: project)/

Added in version 4.3.

透過 PATCH 請求來編輯一個專案。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

PUT /api/projects/(string: project)/

Added in version 4.3.

透過 PUT 請求來編輯一個專案。

參數值:
  • project (string) – 專案 URL slug

DELETE /api/projects/(string: project)/

Deletes a project.

參數值:
  • project (string) – 專案 URL slug

GET /api/projects/(string: project)/changes/

返回項目更改的列表。這本質上是仔細檢查的項目 GET /api/changes/ 接收相同的參數。

參數值:
  • project (string) – 專案 URL slug

Response JSON Object:
GET /api/projects/(string: project)/file/

Added in version 5.5.

Downloads all available translations associated with the project as an archive file using the requested format and language.

參數值:
  • project (string) – 專案 URL slug

查詢參數:
  • format (string) – The archive format to use; If not specified, defaults to zip; Supported formats: zip and zip:CONVERSION where CONVERSION is one of converters listed at 下載翻譯.

  • language_code (string) – The language code to download; If not specified, all languages are included.

GET /api/projects/(string: project)/repository/

回傳版本控制系統(VCS)儲存庫狀態的資訊。這個端點只包含專案所有儲存庫的整體概況。為了得到更多細節,請使用 GET /api/components/(string:project)/(string:component)/repository/

參數值:
  • project (string) – 專案 URL slug

Response JSON Object:
  • needs_commit (boolean) – 是否有待定的更改要送交

  • needs_merge (boolean) – 是否有上游更改要合併

  • needs_push (boolean) – 是否有本地更改要推送

Example JSON data:

{
    "needs_commit": true,
    "needs_merge": false,
    "needs_push": true
}
POST /api/projects/(string: project)/repository/

在版本控制系統(VCS)儲存庫上執行給定的操作。

參數值:
  • project (string) – 專案 URL slug

Request JSON Object:
  • operation (string) – Operation to perform: one of push, pull, commit, reset, cleanup, file-sync, file-scan

Response JSON Object:
  • result (boolean) – 操作的結果

CURL 示例:

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

JSON request example:

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"}

JSON response example:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 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, POST, HEAD, OPTIONS

{"result":true}
GET /api/projects/(string: project)/components/

返回給定項目的翻譯組件列表。

參數值:
  • project (string) – 專案 URL slug

Response JSON Object:
POST /api/projects/(string: project)/components/

在 4.3 版的變更: zipfiledocfile 參數現在可被無 VCS 的元件所接受,見 Local files.

在 4.6 版的變更: 克隆的儲存庫現在使用 內部網址,現在自動在專案中自動共享。使用 isable_autoshare 關閉。

在給定的項目中新建翻譯組件。

提示

從單個 VCS 儲存庫中建立多個元件時,使用 內部網址

備註

多數元件的新建發生在後台。檢查新建元件的 task_url 屬性,並按照那裡的步驟進行。

參數值:
  • project (string) – 專案 URL slug

表格參數:
  • file zipfile – 上傳到 Weblate 用於翻譯初始化的 ZIP 文件

  • file docfile – 要翻譯的文件

  • boolean disable_autoshare – 停用自動儲存庫共享 內部網址

Request JSON Object:
Response JSON Object:

使用“ZipFile``和````````````````````````)無法使用JSON。資料必須上傳為:MimeType:multipart / form-data

CURL form request example:

curl \
    --form docfile=@strings.html \
    --form name=Weblate \
    --form slug=weblate \
    --form file_format=html \
    --form new_lang=add \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/projects/hello/components/

CURL JSON request example:

curl \
    --data-binary '{
        "branch": "main",
        "file_format": "po",
        "filemask": "po/*.po",
        "name": "Weblate",
        "slug": "weblate",
        "repo": "https://github.com/WeblateOrg/hello.git",
        "template": "",
        "new_base": "po/hello.pot",
        "vcs": "git"
    }' \
    -H "Content-Type: application/json" \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/projects/hello/components/

JSON request to create a new component from Git:

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

{
    "branch": "main",
    "file_format": "po",
    "filemask": "po/*.po",
    "name": "Weblate",
    "slug": "weblate",
    "repo": "https://github.com/WeblateOrg/hello.git",
    "template": "",
    "new_base": "po/hello.pot",
    "vcs": "git"
}

JSON request to create a new component from another one:

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

{
    "file_format": "po",
    "filemask": "po/*.po",
    "name": "Weblate",
    "slug": "weblate",
    "repo": "weblate://weblate/hello",
    "template": "",
    "new_base": "po/hello.pot",
    "vcs": "git"
}

JSON response example:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 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, POST, HEAD, OPTIONS

{
    "branch": "main",
    "file_format": "po",
    "filemask": "po/*.po",
    "git_export": "",
    "license": "",
    "license_url": "",
    "name": "Weblate",
    "slug": "weblate",
    "project": {
        "name": "Hello",
        "slug": "hello",
        "source_language": {
            "code": "en",
            "direction": "ltr",
             "population": 159034349015,
            "name": "English",
            "url": "http://example.com/api/languages/en/",
            "web_url": "http://example.com/languages/en/"
        },
        "url": "http://example.com/api/projects/hello/",
        "web": "https://weblate.org/",
        "web_url": "http://example.com/projects/hello/"
    },
    "repo": "file:///home/nijel/work/weblate-hello",
    "template": "",
    "new_base": "",
    "url": "http://example.com/api/components/hello/weblate/",
    "vcs": "git",
    "web_url": "http://example.com/projects/hello/weblate/"
}
GET /api/projects/(string: project)/languages/

對項目內的所有語言返回編頁的統計資料。

參數值:
  • project (string) – 專案 URL slug

Response JSON Object:
  • results (array) – 翻譯統計資料對象的矩陣

  • language (string) – 語言名稱

  • code (string) – 語言代碼

  • total (int) – 字串的總數

  • translated (int) – 已翻譯的字串數量

  • translated_percent (float) – 已翻譯字串的百分比

  • total_words (int) – 詞的總數

  • translated_words (int) – 已翻譯詞的數量

  • words_percent (float) – 已翻譯詞的百分比

GET /api/projects/(string: project)/statistics/

返回項目的統計資料。

參數值:
  • project (string) – 專案 URL slug

也參考

Returned attributes are described in 統計數據.

GET /api/projects/(string: project)/categories/

Added in version 5.0: Returns categories for a project. See GET /api/categories/(int:id)/ for field definitions.

param project:

專案 URL slug

type project:

string

GET /api/projects/(string: project)/labels/

Added in version 5.3: Returns labels for a project.

param project:

專案 URL slug

type project:

string

>json int id:

ID of the label

>json string name:

name of the label

>json string color:

color of the label

POST /api/projects/(string: project)/labels/

Added in version 5.3: Creates a label for a project.

param project:

專案 URL slug

type project:

string

<json string name:

name of the label

<json string color:

color of the label

組件

提示

Use POST /api/projects/(string:project)/components/ to create new components.

GET /api/components/

返回翻譯組件的列表。

也參考

組件對象屬性存檔在 GET /api/components/(string:project)/(string:component)/

GET /api/components/(string: project)/(string: component)/

返回翻譯組件的資訊。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object:

Example JSON data:

{
    "branch": "main",
    "file_format": "po",
    "filemask": "po/*.po",
    "git_export": "",
    "license": "",
    "license_url": "",
    "name": "Weblate",
    "slug": "weblate",
    "project": {
        "name": "Hello",
        "slug": "hello",
        "source_language": {
            "code": "en",
            "direction": "ltr",
             "population": 159034349015,
            "name": "English",
            "url": "http://example.com/api/languages/en/",
            "web_url": "http://example.com/languages/en/"
        },
        "url": "http://example.com/api/projects/hello/",
        "web": "https://weblate.org/",
        "web_url": "http://example.com/projects/hello/"
    },
    "source_language": {
        "code": "en",
        "direction": "ltr",
        "population": 159034349015,
        "name": "English",
        "url": "http://example.com/api/languages/en/",
        "web_url": "http://example.com/languages/en/"
    },
    "repo": "file:///home/nijel/work/weblate-hello",
    "template": "",
    "new_base": "",
    "url": "http://example.com/api/components/hello/weblate/",
    "vcs": "git",
    "web_url": "http://example.com/projects/hello/weblate/"
}
PATCH /api/components/(string: project)/(string: component)/

透過 PATCH 請求來編輯一個元件。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • source_language (string) – 項目源語言代碼(可選)

Request JSON Object:
  • name (string) – name of component

  • slug (string) – slug of component

  • repo (string) – VCS repository URL

CURL 示例:

curl \
    --data-binary '{"name": "new name"}' \
    -H "Content-Type: application/json" \
    -H "Authorization: Token TOKEN" \
    PATCH http://example.com/api/projects/hello/components/

JSON request example:

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

{
    "name": "new name"
}

JSON response example:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 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, POST, HEAD, OPTIONS

{
    "branch": "main",
    "file_format": "po",
    "filemask": "po/*.po",
    "git_export": "",
    "license": "",
    "license_url": "",
    "name": "new name",
    "slug": "weblate",
    "project": {
        "name": "Hello",
        "slug": "hello",
        "source_language": {
            "code": "en",
            "direction": "ltr",
            "population": 159034349015,
            "name": "English",
            "url": "http://example.com/api/languages/en/",
            "web_url": "http://example.com/languages/en/"
        },
        "url": "http://example.com/api/projects/hello/",
        "web": "https://weblate.org/",
        "web_url": "http://example.com/projects/hello/"
    },
    "repo": "file:///home/nijel/work/weblate-hello",
    "template": "",
    "new_base": "",
    "url": "http://example.com/api/components/hello/weblate/",
    "vcs": "git",
    "web_url": "http://example.com/projects/hello/weblate/"
}
PUT /api/components/(string: project)/(string: component)/

透過 PUT 請求來編輯一個元件。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Request JSON Object:
  • branch (string) – VCS repository branch

  • file_format (string) – 翻譯的文件格式

  • filemask (string) – 儲存庫中翻譯檔的遮罩

  • name (string) – name of component

  • slug (string) – slug of component

  • repo (string) – VCS repository URL

  • template (string) – 但語言翻譯的譯文模板文件

  • new_base (string) – 用於新增新翻譯的譯文模板文件

  • vcs (string) – version control system

DELETE /api/components/(string: project)/(string: component)/

Deletes a component.

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

GET /api/components/(string: project)/(string: component)/changes/

返回組件更改的列表。這本質上是仔細檢查的組件 :http:get:`/api/changes/`接相同參數。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object:
GET /api/components/(string: project)/(string: component)/file/

Added in version 4.9.

Downloads all available translations associated with the component as an archive file using the requested format.

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

查詢參數:
  • format (string) – The archive format to use; If not specified, defaults to zip; Supported formats: zip and zip:CONVERSION where CONVERSION is one of converters listed at 下載翻譯.

GET /api/components/(string: project)/(string: component)/screenshots/

返回組件螢幕截圖的列表。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object:
GET /api/components/(string: project)/(string: component)/lock/

返回組件鎖定狀態。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object:
  • locked (boolean) – 組件是否因更新而鎖定

Example JSON data:

{
    "locked": false
}
POST /api/components/(string: project)/(string: component)/lock/

設定組件鎖定狀態。

響應時間與 :http:get:`/api/components/(string:project)/(string:component)/lock/`相同。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Request JSON Object:
  • lock – 是否鎖定的布爾值。

CURL 示例:

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

JSON request example:

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

{"lock": true}

JSON response example:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 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, POST, HEAD, OPTIONS

{"locked":true}
GET /api/components/(string: project)/(string: component)/repository/

回傳版本控制系統(VCS)儲存庫狀態的資訊。

響應與 GET /api/projects/(string:project)/repository/ 的相同。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object:
  • needs_commit (boolean) – 是否有待定的更改要送交

  • needs_merge (boolean) – 是否有上游更改要合併

  • needs_push (boolean) – 是否有本地更改要推送

  • remote_commit (string) – Remote commit information

  • status (string) – 由版本控制系統(VCS)報告的 VCS 狀態

  • merge_failure – 描述合併失敗的文本,沒有的話為空

POST /api/components/(string: project)/(string: component)/repository/

在版本控制系統(VCS)儲存庫執行給定的操作。

文件請參見 POST /api/projects/(string:project)/repository/

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Request JSON Object:
  • operation (string) – 執行的操作: push, pull, commit, reset, ``cleanup``之一

Response JSON Object:
  • result (boolean) – 操作的結果

CURL 示例:

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

JSON request example:

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

{"operation":"pull"}

JSON response example:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 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, POST, HEAD, OPTIONS

{"result":true}
GET /api/components/(string: project)/(string: component)/monolingual_base/

為單語言翻譯下載譯文模板文件。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

GET /api/components/(string: project)/(string: component)/new_template/

為新的翻譯下載模板文件。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

GET /api/components/(string: project)/(string: component)/translations/

返回給定組件中翻譯對象的列表。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object:
POST /api/components/(string: project)/(string: component)/translations/

在給定組件中新建新的翻譯。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Request JSON Object:
Response JSON Object:
  • result (object) – 新建的新翻譯對象

CURL 示例:

curl \
    -d language_code=cs \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/projects/hello/components/

JSON request example:

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

{"language_code": "cs"}

JSON response example:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 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, POST, HEAD, OPTIONS

{
    "failing_checks": 0,
    "failing_checks_percent": 0,
    "failing_checks_words": 0,
    "filename": "po/cs.po",
    "fuzzy": 0,
    "fuzzy_percent": 0.0,
    "fuzzy_words": 0,
    "have_comment": 0,
    "have_suggestion": 0,
    "is_template": false,
    "is_source": false,
    "language": {
        "code": "cs",
        "direction": "ltr",
        "population": 1303174280
        "name": "Czech",
        "url": "http://example.com/api/languages/cs/",
        "web_url": "http://example.com/languages/cs/"
    },
    "language_code": "cs",
    "id": 125,
    "last_author": null,
    "last_change": null,
    "share_url": "http://example.com/engage/hello/cs/",
    "total": 4,
    "total_words": 15,
    "translate_url": "http://example.com/translate/hello/weblate/cs/",
    "translated": 0,
    "translated_percent": 0.0,
    "translated_words": 0,
    "url": "http://example.com/api/translations/hello/weblate/cs/",
    "web_url": "http://example.com/projects/hello/weblate/cs/"
}
GET /api/components/(string: project)/(string: component)/statistics/

對組件內所有的翻譯返回分頁的統計資料。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

也參考

Returned attributes are described in 統計數據.

Returns projects linked with a component.

Added in version 4.5.

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object:
POST /api/components/(string: project)/(string: component)/links/

Associate project with a component.

Added in version 4.5.

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

表格參數:
  • string project_slug – 項目標識串

Remove association of a project with a component.

Added in version 4.5.

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • project_slug (string) – Slug of the project to remove

翻譯

GET /api/translations/

返回翻譯的列表。

GET /api/translations/(string: project)/(string: component)/(string: language)/

返回翻譯的資訊。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Response JSON Object:

Example JSON data:

{
    "component": {
        "branch": "main",
        "file_format": "po",
        "filemask": "po/*.po",
        "git_export": "",
        "license": "",
        "license_url": "",
        "name": "Weblate",
        "new_base": "",
        "project": {
            "name": "Hello",
            "slug": "hello",
            "source_language": {
                "code": "en",
                "direction": "ltr",
                "population": 159034349015,
                "name": "English",
                "url": "http://example.com/api/languages/en/",
                "web_url": "http://example.com/languages/en/"
            },
            "url": "http://example.com/api/projects/hello/",
            "web": "https://weblate.org/",
            "web_url": "http://example.com/projects/hello/"
        },
        "repo": "file:///home/nijel/work/weblate-hello",
        "slug": "weblate",
        "template": "",
        "url": "http://example.com/api/components/hello/weblate/",
        "vcs": "git",
        "web_url": "http://example.com/projects/hello/weblate/"
    },
    "failing_checks": 3,
    "failing_checks_percent": 75.0,
    "failing_checks_words": 11,
    "filename": "po/cs.po",
    "fuzzy": 0,
    "fuzzy_percent": 0.0,
    "fuzzy_words": 0,
    "have_comment": 0,
    "have_suggestion": 0,
    "is_template": false,
    "language": {
        "code": "cs",
        "direction": "ltr",
        "population": 1303174280
        "name": "Czech",
        "url": "http://example.com/api/languages/cs/",
        "web_url": "http://example.com/languages/cs/"
    },
    "language_code": "cs",
    "last_author": "Weblate Admin",
    "last_change": "2016-03-07T10:20:05.499",
    "revision": "7ddfafe6daaf57fc8654cc852ea6be212b015792",
    "share_url": "http://example.com/engage/hello/cs/",
    "total": 4,
    "total_words": 15,
    "translate_url": "http://example.com/translate/hello/weblate/cs/",
    "translated": 4,
    "translated_percent": 100.0,
    "translated_words": 15,
    "url": "http://example.com/api/translations/hello/weblate/cs/",
    "web_url": "http://example.com/projects/hello/weblate/cs/"
}
DELETE /api/translations/(string: project)/(string: component)/(string: language)/

Deletes a translation.

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

GET /api/translations/(string: project)/(string: component)/(string: language)/changes/

返回翻譯更改的列表。這本質上是仔細檢查的翻譯 :http:get:`/api/changes/`接受相同參數。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Response JSON Object:
GET /api/translations/(string: project)/(string: component)/(string: language)/units/

返回翻譯單元的列表。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

  • q (string) – 搜尋查詢字串 :ref:`Searching`(選用)

Response JSON Object:
POST /api/translations/(string: project)/(string: component)/(string: language)/units/

Add new unit.

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Request JSON Object:
  • key (string) – Monolingual translations: Key of translation unit

  • value (array) – Monolingual translations: Source strings (use single string if not creating plural)

  • context (string) – Bilingual translations: Context of a translation unit

  • source (array) – Bilingual translations: Source strings (use single string if not creating plural)

  • target (array) – Bilingual translations: Target strings (use single string if not creating plural)

  • state (int) – String state; see GET /api/units/(int:id)/

Response JSON Object:
POST /api/translations/(string: project)/(string: component)/(string: language)/autotranslate/

觸發自動翻譯。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Request JSON Object:
  • mode (string) – 自動翻譯模式

  • filter_type (string) – 自動翻譯篩選類型

  • auto_source (string) – Automatic translation source - mt or others

  • component (string) – 開啟對專案的共享翻譯記憶作貢獻,以取得其他組件的存取權。

  • engines (array) – 機器翻譯引擎

  • threshold (string) – 分數閾值

GET /api/translations/(string: project)/(string: component)/(string: language)/file/

下載儲存在 VCS 中的目前翻譯文件(不帶 ``format``參數)或將其轉換為另一格式(見 下載翻譯)。

備註

這個 API 端點使用了不同於API其餘的邏輯來輸出,它在整個文件而不是在資料上操作。接受的``format``參數組不同,沒有這個參數會將翻譯文件儲存在版本控制系統(VCS)中。

響應標頭:
請求標頭:
  • If-Modified-Since – Skips response if the file has not been modified since that time.

查詢參數:
  • format – File format to use; if not specified no format conversion happens; see 下載翻譯 for supported formats

  • q (string) – Filter downloaded strings, see 搜尋頁面, only applicable when conversion is in place (format is specified).

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

POST /api/translations/(string: project)/(string: component)/(string: language)/file/

上傳帶有翻譯的新文件。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

表格參數:
  • string conflicts – How to deal with conflicts (ignore, replace-translated or replace-approved), see 衝突處理

  • file file – 上傳文件

  • string email – 作者郵件信箱

  • string author – 作者姓名

  • string method – 上傳方法(translate, approve, suggest, fuzzy, replace, source, add),見:ref: upload-method

  • string fuzzy – 模糊 (標記為需要編輯)的字串處理(empty, process, approve

CURL 示例:

curl -X POST \
    -F file=@strings.xml \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/translations/hello/android/cs/file/
GET /api/translations/(string: project)/(string: component)/(string: language)/repository/

回傳版本控制系統(VCS)儲存庫狀態的資訊。

響應與 :http:get:`/api/components/(string:project)/(string:component)/repository/`的相同。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

POST /api/translations/(string: project)/(string: component)/(string: language)/repository/

在版本控制系統(VCS)儲存庫上執行給定的操作。

文件請參見 POST /api/projects/(string:project)/repository/

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Request JSON Object:
  • operation (string) – 執行的操作: push, pull, commit, reset, ``cleanup``之一

Response JSON Object:
  • result (boolean) – 操作的結果

GET /api/translations/(string: project)/(string: component)/(string: language)/statistics/

返回具體的翻譯統計資料。

參數值:
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

也參考

Returned attributes are described in 統計數據.

記憶

Added in version 4.14.

GET /api/memory/

Returns a list of memory results.

DELETE /api/memory/(int: memory_object_id)/

Deletes a memory object

參數值:
  • memory_object_id – Memory Object ID

Units

“單位”是一個翻譯的單曲,它對具有相應翻譯的字串對的來源字串,也包含一些相關元資料。該術語來自“翻譯工具包”<http://docs.translatehouse.org/projects/translate-toolkit/en/latest/api/storage.html#translate.storage.base.translationUnit>`_和xliff。

GET /api/units/

返回翻譯單元的列表。

參數值:
  • q (string) – 搜尋查詢字串 :ref:`Searching`(選用)

也參考

單元對象屬性存檔在 GET /api/units/(int:id)/

GET /api/units/(int: id)/

在 4.3 版的變更: targetsource 現在是矩陣,來適當的處理多個字串。

返回翻譯單元的資訊。

參數值:
  • id (int) – 單元 ID

Response JSON Object:
  • translation (string) – 相關翻譯對象的 URL

  • source (array) – 來源字串

  • previous_source (string) – 用於模糊匹配的之前的源字串

  • target (array) – 目標字串

  • id_hash (string) – 單元的唯一識別文字

  • content_hash (string) – 源字串的唯一識別文字

  • location (string) – 來源碼中單元的位置

  • context (string) – 翻譯單元的語境

  • note (string) – 翻譯單元的註解

  • flags (string) – 翻譯單元的標記

  • labels (array) – translation unit labels, available on source units

  • state (int) – unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved, 100 - read only

  • fuzzy (boolean) – 是否為 fuzzy 或標記為需檢閱

  • translated (boolean) – whether the unit is translated

  • approved (boolean) – whether the translation is approved

  • position (int) – 翻譯文件中的單元位置

  • has_suggestion (boolean) – whether the unit has suggestions

  • has_comment (boolean) – whether the unit has comments

  • has_failing_check (boolean) – whether the unit has failing checks

  • num_words (int) – 源詞彙的數量

  • priority (int) – 翻譯優先級;100為預設值

  • id (int) – 單元識別問題

  • explanation (string) – 字串的解釋,可在源單元獲得,請參見 源字串另外的資訊

  • extra_flags (string) – 另外的字串標記,可在源單元獲得,請參見 使用標誌自定義行為

  • web_url (string) – 單元可以被編輯的 URL

  • source_unit (string) – 源單元連結;請參見 GET /api/units/(int:id)/

  • pending (boolean) – 是否為等候寫入

  • timestamp (timestamp) – string age

PATCH /api/units/(int: id)/

Added in version 4.3.

Performs partial update on translation unit.

參數值:
  • id (int) – 單元 ID

Request JSON Object:
  • state (int) – unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved (need review workflow enabled, see 專門的審核者)

  • target (array) – 目標字串

  • explanation (string) – 字串的解釋,可在源單元獲得,請參見 源字串另外的資訊

  • extra_flags (string) – 另外的字串標記,可在源單元獲得,請參見 使用標誌自定義行為

Response JSON Object:
  • labels (array) – labels, available on source units

PUT /api/units/(int: id)/

Added in version 4.3.

Performs full update on translation unit.

參數值:
  • id (int) – 單元 ID

Request JSON Object:
  • state (int) – unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved (need review workflow enabled, see 專門的審核者)

  • target (array) – 目標字串

  • explanation (string) – 字串的解釋,可在源單元獲得,請參見 源字串另外的資訊

  • extra_flags (string) – 另外的字串標記,可在源單元獲得,請參見 使用標誌自定義行為

Response JSON Object:
  • labels (array) – labels, available on source units

DELETE /api/units/(int: id)/

Added in version 4.3.

Deletes a translation unit.

參數值:
  • id (int) – 單元 ID

更動

GET /api/changes/

在 4.1 版的變更: 更改的篩選在 4.1 版本引入。

返回翻譯更改的列表。

也參考

更改對象的屬性存檔在 GET /api/changes/(int:id)/

查詢參數:
  • user (string) – 篩選使用者的使用者名稱

  • action (int) – 篩選的動作,可以多次使用

  • timestamp_after (timestamp) – ISO 8601 格式的時間標籤,列出此時間之後的更改

  • timestamp_before (timestamp) – ISO 8601 格式的時間標籤,列出此時間之前的更改

GET /api/changes/(int: id)/

返回有關翻譯更改的資訊。

參數值:
  • id (int) – 變更 ID

Response JSON Object:
  • unit (string) – 相關單元物件的網址

  • translation (string) – 相關翻譯對象的 URL

  • component (string) – 相關組件物件的網址

  • user (string) – 相關使用者對象的 URL

  • author (string) – 相關作者對象的 URL

  • timestamp (timestamp) – 事件時間戳記

  • action (int) – 動作的幾種識別

  • action_name (string) – 動作的文本描述

  • target (string) – 更改的事件的文本或細節

  • id (int) – 更改的識別文字

螢幕擷圖

GET /api/screenshots/

返回螢幕截圖字串資訊的列表。

也參考

螢幕截圖對象的屬性存檔在 GET /api/screenshots/(int:id)/

GET /api/screenshots/(int: id)/

返回與螢幕截圖資訊有關的資訊。

參數值:
  • id (int) – 螢幕擷圖 ID

Response JSON Object:
GET /api/screenshots/(int: id)/file/

下載螢幕截圖的圖片。

參數值:
  • id (int) – 螢幕擷圖 ID

POST /api/screenshots/(int: id)/file/

替換螢幕截圖。

參數值:
  • id (int) – 螢幕擷圖 ID

表格參數:
  • file image – 上傳文件

CURL 示例:

curl -X POST \
    -F image=@image.png \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/screenshots/1/file/
POST /api/screenshots/(int: id)/units/

與螢幕截圖相關的源字串。

參數值:
  • id (int) – 螢幕擷圖 ID

表格參數:
  • string unit_id – 單元 ID

Response JSON Object:
DELETE /api/screenshots/(int: id)/units/(int: unit_id)

Remove source string association with screenshot.

參數值:
  • id (int) – 螢幕擷圖 ID

  • unit_id – Source string unit ID

POST /api/screenshots/

新建新的螢幕截圖。

表格參數:
  • file image – 上傳文件

  • string name – 畫面快照名稱

  • string project_slug – 項目標識串

  • string component_slug – 組件標識串

  • string language_code – 語言碼

Response JSON Object:
PATCH /api/screenshots/(int: id)/

Edit partial information about screenshot.

參數值:
  • id (int) – 螢幕擷圖 ID

Response JSON Object:
PUT /api/screenshots/(int: id)/

Edit full information about screenshot.

參數值:
  • id (int) – 螢幕擷圖 ID

Response JSON Object:
DELETE /api/screenshots/(int: id)/

Delete screenshot.

參數值:
  • id (int) – 螢幕擷圖 ID

附加元件

Added in version 4.4.1.

GET /api/addons/

返回附加元件列表。

也參考

附加元件對象屬性記錄在 GET /api/units/(int:id)/

GET /api/addons/(int: id)/

Returns information about add-on information.

參數值:
  • id (int) – Add-on ID

Response JSON Object:
  • name (string) – name of an add-on

  • component (string) – 相關組件物件的網址

  • configuration (object) – Optional add-on configuration

也參考

附加元件

POST /api/components/(string: project)/(string: component)/addons/

Creates a new add-on.

參數值:
  • project_slug (string) – 項目標識串

  • component_slug (string) – 組件標識串

Request JSON Object:
  • name (string) – name of an add-on

  • configuration (object) – Optional add-on configuration

PATCH /api/addons/(int: id)/

Edit partial information about add-on.

參數值:
  • id (int) – Add-on ID

Response JSON Object:
  • configuration (object) – Optional add-on configuration

PUT /api/addons/(int: id)/

Edit full information about add-on.

參數值:
  • id (int) – Add-on ID

Response JSON Object:
  • configuration (object) – Optional add-on configuration

DELETE /api/addons/(int: id)/

Delete add-on.

參數值:
  • id (int) – Add-on ID

組件列表

Added in version 4.0.

GET /api/component-lists/

返回組件列表的列表。

也參考

組件列表對象屬性存檔在 GET /api/component-lists/(str:slug)/

GET /api/component-lists/(str: slug)/

返回組件列表的資訊。

參數值:
  • slug (string) – 組件列表的標識串

Response JSON Object:
  • name (string) – 組件列表的名稱

  • slug (string) – 組件列表的表示串

  • show_dashboard (boolean) – 是否在控制台上顯示

  • components (array) – 相關聯組件的連接;請參見 GET /api/components/(string:project)/(string:component)/

  • auto_assign (array) – 自動分配規則

PUT /api/component-lists/(str: slug)/

更改組件列表參數。

參數值:
  • slug (string) – 組件列表的標識串

Request JSON Object:
  • name (string) – 組件列表的名稱

  • slug (string) – 組件列表的表示串

  • show_dashboard (boolean) – 是否在控制台上顯示

PATCH /api/component-lists/(str: slug)/

更改組件列表參數。

參數值:
  • slug (string) – 組件列表的標識串

Request JSON Object:
  • name (string) – 組件列表的名稱

  • slug (string) – 組件列表的表示串

  • show_dashboard (boolean) – 是否在控制台上顯示

DELETE /api/component-lists/(str: slug)/

刪除組件列表。

參數值:
  • slug (string) – 組件列表的標識串

GET /api/component-lists/(str: slug)/components/

Added in version 5.0.1: List components in a component list.

param slug:

組件列表的標識串

type slug:

string

form string component_id:

組件 ID

>json array results:

組件對象的矩陣;請參見 GET /api/components/(string:project)/(string:component)/

POST /api/component-lists/(str: slug)/components/

使組件與組件列表相關。

參數值:
  • slug (string) – 組件列表的標識串

表格參數:
  • string component_id – 組件 ID

DELETE /api/component-lists/(str: slug)/components/(str: component_slug)

將組件與組件列表接觸相關性。

參數值:
  • slug (string) – 組件列表的標識串

  • component_slug (string) – 組件標識串

詞彙表

在 4.5 版的變更: 表格現在儲存為常規元件,翻譯和字串,請使用相應的API。

任務

Added in version 4.4.

GET /api/tasks/

Listing of the tasks is currently not available.

GET /api/tasks/(str: uuid)/

Returns information about a task.

參數值:
  • uuid (string) – 任務 UUID

Response JSON Object:
  • completed (boolean) – Whether the task has completed

  • progress (int) – Task progress in percent

  • result (object) – 任務結果或過程細節

  • log (string) – Task log

統計數據

GET /api/(str: object)/statistics/

There are several statistics endpoints for objects and all of them contain same structure.

參數值:
  • object (string) – URL path

Response JSON Object:
  • total (int) – 字串的總數

  • total_words (int) – 詞的總數

  • total_chars (int) – total number of characters

  • last_change (timestamp) – 上次更改的日期

  • translated (int) – 已翻譯的字串數量

  • translated_percent (float) – 已翻譯字串的百分比

  • translated_words (int) – 已翻譯詞的數量

  • translated_words_percent (float) – 已翻譯詞的百分比

  • translated_chars (int) – 已翻譯字元的數量

  • translated_chars_percent (float) – 已翻譯字元的百分比

  • fuzzy (int) – number of fuzzy (marked for edit) strings

  • fuzzy_words (int) – number of fuzzy (marked for edit) words

  • fuzzy_chars (int) – number of fuzzy (marked for edit) characters

  • fuzzy_percent (float) – 模糊字串 (標記為需要編輯)的百分比

  • fuzzy_words_percent (float) – percentage of fuzzy (marked for edit) words

  • fuzzy_chars_percent (float) – percentage of fuzzy (marked for edit) characters

  • failing (int) – 檢查失敗的數量

  • failing_percent (float) – 檢查失敗的百分比

  • approved (int) – number of approved strings

  • approved_words (int) – number of approved words

  • approved_chars (int) – number of approved characters

  • approved_percent (float) – percentage of approved strings

  • approved_words_percent (float) – percentage of approved words

  • approved_chars_percent (float) – percentage of approved characters

  • readonly (int) – number of read-only strings

  • readonly_words (int) – number of read-only words

  • readonly – number of read-only characters

  • readonly_percent (float) – percentage of read-only strings

  • readonly_words_percent (float) – percentage of read-only words

  • readonly_char_percent (float) – percentage of read-only characters

  • suggestions (int) – number of strings with suggestions

  • comments (int) – number of strings with comments

  • name (string) – object name

  • url (string) – URL to access the object (if applicable)

  • url_translate (string) – URL to access the translation (if applicable)

  • code (string) – language code (if applicable)

指標

GET /api/metrics/

Returns server metrics.

Response JSON Object:
  • units (int) – Number of units

  • units_translated (int) – Number of translated units

  • users (int) – Number of users

  • changes (int) – 變更數

  • projects (int) – Number of projects

  • components (int) – 元件數目

  • translations (int) – Number of translations

  • languages (int) – Number of used languages

  • checks (int) – Number of triggered quality checks

  • configuration_errors (int) – Number of configuration errors

  • suggestions (int) – Number of pending suggestions

  • celery_queues (object) – Celery 排程序列的長度。參閱 使用 Celery 的後台任務

  • name (string) – Configured server name

Categories

GET /api/categories/

Added in version 5.0.

Lists available categories. See GET /api/categories/(int:id)/ for field definitions.

POST /api/categories/

Added in version 5.0.

Creates a new category. See GET /api/categories/(int:id)/ for field definitions.

GET /api/categories/(int: id)/

Added in version 5.0.

參數值:
  • id (int) – Category ID

Response JSON Object:
  • name (str) – Name of category.

  • slug (str) – Slug of category.

  • project (str) – Link to a project.

  • category (str) – Link to a parent category.

PATCH /api/categories/(int: id)/

Added in version 5.0: Edit partial information about category.

param id:

Category ID

type id:

int

>json object configuration:

Optional category configuration

PUT /api/categories/(int: id)/

Added in version 5.0: Edit full information about category.

param id:

Category ID

type id:

int

>json object configuration:

Optional category configuration

DELETE /api/categories/(int: id)/

Added in version 5.0: Delete category.

param id:

Category ID

type id:

int

GET /api/categories/(int: id)/statistics/

Added in version 5.5.

Returns statistics for a category.

參數值:
  • project (int) – Category id

也參考

Returned attributes are described in 統計數據.

通知掛勾

通知鉤子允許外部應用來通知 Weblate 版本控制系統(VCS)儲存庫已經更新。

可以為專案、組件和翻譯使用儲存庫端點來更新各自的儲存庫;文件請參見 POST /api/projects/(string:project)/repository/

GET /hooks/update/(string: project)/(string: component)/

在 2.6 版之後被棄用: 請使用 POST /api/components/(string:project)/(string:component)/repository/ 來替代,它使用 ACL 限制的身份驗證而工作正常。

觸發組件的更新(從版本控制系統 VCS 拉取並掃描翻譯的更改)。

GET /hooks/update/(string: project)/

在 2.6 版之後被棄用: 請使用 POST /api/projects/(string:project)/repository/ 來替代,它使用 ACL 限制的身份驗證而工作正常。

觸發項目中所有組件的更新(從版本控制系統 VCS 拉取並掃描翻譯的更改)。

POST /hooks/github/

處理 Github 通知與自動更新匹配組件的特殊鉤子。

備註

GitHub 包括了對通知 Weblate 的直接支援:在儲存庫設定中啟動 Weblate 服務掛勾,並將 URL 設定為您的 Weblate 安裝的 URL。

也參考

從 GitHub 自動接收更改

關於設定 Github 整合的指令

https://docs.github.com/en/get-started/customizing-your-github-workflow/exploring-integrations/about-webhooks

GitHub Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/gitlab/

處理 GitLab 通知並自動更新匹配組件的特殊鉤子。

也參考

從 GitLab 自動接收更改

關於設定 GitLab 整合的指示

https://docs.gitlab.com/ee/user/project/integrations/webhooks.html

關於 GitLab Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/bitbucket/

處理 Bitbucket 通知並自動更新匹配的組件的特殊鉤子。

也參考

從 Bitbucket 自動接收更改

關於設定 Bitbucket 整合的指示

https://support.atlassian.com/bitbucket-cloud/docs/manage-webhooks/

關於 Bitbucket Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/pagure/

處理 Pagure 通知並自動更新匹配的組件的特殊鉤子。

也參考

從 Pagure 自動接受更改

關於設定 Pagure 整合的指示

https://docs.pagure.org/pagure/usage/using_webhooks.html

關於 Pagure Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/azure/

Special hook for handling Azure DevOps notifications and automatically updating matching components.

備註

Please ensure that Resource details to send is set to All, otherwise Weblate will not be able to match your Azure repository.

也參考

從 Azure Repos 自動接收更改

關於設定 Azure 整合的指示

https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops

Generic information about Azure DevOps Web Hooks

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/gitea/

處理 Gitea Webhook 通知並自動更新匹配的組件的特殊鉤子。

也參考

從 Gitea Repos 自動接收更改

關於設定 Gitea 整合的指示

https://docs.gitea.io/en-us/webhooks/

關於 Gitea Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/gitee/

處理 Gitee Webhook 通知並自動更新匹配的組件的特殊鉤子。

也參考

從 Gitee Repos 自動接收更改

關於設定 Gitee 整合的指示

https://gitee.com/help/categories/40

關於 Gitee Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

Exports

Weblate 提供各種導出,允許進一步處理資料。

GET /exports/stats/(string: project)/(string: component)/
查詢參數:
  • format (string) – 輸出格式: jsoncsv

在 2.6 版之後被棄用: 請替代使用:http:get:/api/components/(string:project)/(string:component)/statistics/ 和:http:get:/api/translations/(string:project)/(string: component)/(string:language)/statistics/;它也允許存取ACL 控制的項目。

為給定的組件以給定的格式檢索統計資料。

示例請求:

GET /exports/stats/weblate/main/ HTTP/1.1
Host: example.com
Accept: application/json, text/javascript

示例響應:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
    {
        "code": "cs",
        "failing": 0,
        "failing_percent": 0.0,
        "fuzzy": 0,
        "fuzzy_percent": 0.0,
        "last_author": "Michal Čihař",
        "last_change": "2012-03-28T15:07:38+00:00",
        "name": "Czech",
        "total": 436,
        "total_words": 15271,
        "translated": 436,
        "translated_percent": 100.0,
        "translated_words": 3201,
        "url": "http://hosted.weblate.org/engage/weblate/cs/",
        "url_translate": "http://hosted.weblate.org/projects/weblate/main/cs/"
    },
    {
        "code": "nl",
        "failing": 21,
        "failing_percent": 4.8,
        "fuzzy": 11,
        "fuzzy_percent": 2.5,
        "last_author": null,
        "last_change": null,
        "name": "Dutch",
        "total": 436,
        "total_words": 15271,
        "translated": 319,
        "translated_percent": 73.2,
        "translated_words": 3201,
        "url": "http://hosted.weblate.org/engage/weblate/nl/",
        "url_translate": "http://hosted.weblate.org/projects/weblate/main/nl/"
    },
    {
        "code": "el",
        "failing": 11,
        "failing_percent": 2.5,
        "fuzzy": 21,
        "fuzzy_percent": 4.8,
        "last_author": null,
        "last_change": null,
        "name": "Greek",
        "total": 436,
        "total_words": 15271,
        "translated": 312,
        "translated_percent": 71.6,
        "translated_words": 3201,
        "url": "http://hosted.weblate.org/engage/weblate/el/",
        "url_translate": "http://hosted.weblate.org/projects/weblate/main/el/"
    }
]

RSS 消息來源

翻譯的更改導出到 RSS 頻道。

GET /exports/rss/(string: project)/(string: component)/(string: language)/

用翻譯近期的更改檢索 RSS 頻道。

GET /exports/rss/(string: project)/(string: component)/

用組件的近期更改檢索 RSS 頻道。

GET /exports/rss/(string: project)/

用項目的近期更改檢索 RSS 頻道。

GET /exports/rss/language/(string: language)/

用語言的近期更改檢索 RSS 頻道。

GET /exports/rss/

用 Weblate 事件的近期更改檢索 RSS 頻道。

也參考

RSS on Wikipedia