WebTranslateIt API » TermBase API
The TermBase API is composed of 5 endpoints:
- List Terms — list terms
- Show Term — show a term
- Create Term — create a term
- Update Term — update a term
- Delete Term — delete a term and its translations
- TermBase to TBX NEW — Download all terms to a TBX file
List Terms
This endpoint is accessible by the private API key and is used to list terms.
/api/projects/:project_token/terms.format [GET]
Where format is one of xml, json, or yaml. Note that you can get a JSONP response by adding a ?callback=yourFunctionName parameter to the json API call.
This resource is paginated and serves 250 Terms per page. In the server response headers, you will find Link, with a link for an API call to the next and last pages.
Parameters
page: Page number.
Example query:
https://webtranslateit.com/api/projects/4af21ce1fb3a4f7127a60b31ebc41c1446b38bb2/terms
Example response with JSON:
[
{
"id": 1234,
"text": "User",
"description": "Someone using the WebTranslateIt service.",
"created_at": "2010-02-09T23:23:45Z",
"updated_at": "2011-10-28T13:54:13Z",
},
{
"id": 1235,
"text": "Segment",
"description": "A portion of text to translate.",
"created_at": "2010-02-09T23:23:45Z",
"updated_at": "2011-10-28T13:54:13Z",
}
]
Show Term
This endpoint is only accessible by the private API key and is used to show a term.
/api/projects/:project_token/terms/:term_id.format [GET]
Where format is one of xml, json or yaml. Note that you can get a JSONP response by adding a ?callback=yourFunctionName parameter to the json API call.
Example response with JSON:
{
"id": 1234,
"text": "User",
"description": "Someone using the WebTranslateIt service.",
"created_at": "2010-02-09T23:23:45Z",
"updated_at": "2011-10-28T13:54:13Z",
}
Example Implementation in Ruby
require 'net/http'
http = Net::HTTP.new('webtranslateit.com', 443)
request = Net::HTTP::Get.new("/api/projects/:api_token/terms/:term_id")
http.request(request)
Example Implementation in PHP
<?php
$api_key = "sekret";
$term_id = "1234";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://webtranslateit.com/api/projects/" . $api_key . "/terms/". $term_id . ".json");
$response = curl_exec($ch);
$p = json_decode($response, true);
print_r($p);
curl_close($ch);
?>
Create Term
This endpoint is only accessible by the private API key and is used to create a new term.
/api/projects/:project_token/terms [POST]
Parameters
A JSON object modelled after the following:
{
"text": "Term",
"description": "An optional description"
}
The description field is optional. If everything goes Well, WebTranslateIt will respond with 201 Created in the header and a JSON representation of the term just created in the body.
NEW You can also create one or several Term Translations while creating a Term by passing an optional array of Translation:
{
"text": "Term",
"description": "An optional description",
"translations": [
{
"locale": "fr",
"text": "Terme",
"description": "La traduction de la description",
"status": "approved"
},
{
"locale": "es",
"text": "Terminología",
"description": "",
"status": "refused"
}
]
}
In this array of Translation, locale and text are mandatory. status is optional (defaults to proposed).
status can be one of approved, refused or proposed.
Example Implementation in Ruby
require 'net/http'
require 'json'
http = Net::HTTP.new('webtranslateit.com', 443)
http.use_ssl = true
request = Net::HTTP::Post.new("/api/projects/:api_token/terms", initheader = {'Content-Type' =>'application/json'})
request.body = { "text" => "term", "description" => "An optional description" }.to_json
http.request(request)
Example Implementation in PHP
<?php
$api_key = "sekret";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://webtranslateit.com/api/projects/" . $api_key . "/terms");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("text" => "term", 'dev_comment' => "An optional description"));
$response = curl_exec($ch);
print_r($response);
curl_close($ch);
?>
Update Term
This endpoint is only accessible by the private API key and is used to update an existing term.
/api/projects/:project_token/terms/:term_id [PUT]
Parameters
A JSON object modelled after the following:
{
"text": "Term",
"description": "An optional description"
}
The description field is optional. Only provided fields will be modified.
If everything goes Well, WebTranslateIt will respond with 202 Accepted in the header and a JSON representation of the term just updated in the body.
Example Implementation in Ruby
require 'net/http'
require 'json'
http = Net::HTTP.new('webtranslateit.com', 443)
http.use_ssl = true
request = Net::HTTP::Put.new("/api/projects/:api_token/terms/:term_id", initheader = {'Content-Type' =>'application/json'})
request.body = { "text" => "Term", "description" => "An optional description" }.to_json
http.request(request)
Example Implementation in PHP
<?php
$api_key = "sekret";
$term_id = "1234";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://webtranslateit.com/api/projects/" . $api_key . "/terms/" . $term_id);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, array("text" => "Term", 'description' => "An optional description"));
$response = curl_exec($ch);
print_r($response);
curl_close($ch);
?>
Delete Term
This endpoint is only accessible by the private API key and is used to delete a term and its translations.
/api/projects/:project_token/terms/:term_id [DELETE]
Example Implementation in Ruby
require 'net/http'
http = Net::HTTP.new('webtranslateit.com', 443)
request = Net::HTTP::Delete.new("/api/projects/:api_token/terms/:term_id")
http.request(request)
Example Implementation in PHP
<?php
$api_key = "sekret";
$term_id = "1234";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://webtranslateit.com/api/projects/" . $api_key . "/terms/" . $term_id);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
$response = curl_exec($ch);
print_r($response);
curl_close($ch);
?>
TermBase to TBX
This endpoint is accessible by both the private and public API keys and is used to download a termbase as a TermBase Exchange file (TBX).
/api/projects/:project_token/terms/to_tbx [GET]
For more information about TBX files, please refer to the TBX specifications.
An optional parameter, locale=xx can be passed to get a TBX file containing only the source_locale and locale language pairs.
