This endpoint retrieves all translations. It takes an array of sentences in an original language in input and outputs the same array of sentences but translated in another language.
The body is sent in the JSON format
Query Parameters
Name
Type
Description
api_key
string
Your Weglot API Key
Headers
Name
Type
Description
Content-Type
string
application/json
Request Body
Name
Type
Description
l_from
string
ISO 639-1 code of the original language
l_to
string
ISO 639-1 code of the destination language
words
array
Sentences in original language
words[t]
integer
Type of the word based on WordType resource
words[w]
string
Sentence to translate
bot
integer
Link to user agent based on BotType resource
request_url
string
URL where the request come from
title
string
Title of the page where these sentences come from
You can find WordType and BotType resources at the end of this document.
Here is a simple request example:
Resources
BotType
Used to define the source of a request.
Short-Name
Value
Description
HUMAN
0
Sent from human action
OTHER
1
Sent from unknown source
GOOGLE
2
Sent from Google Bot
BING
3
Sent from Bing Bot
YAHOO
4
Sent from Yahoo Bot
BAIDU
5
Sent from Baidu Bot
YANDEX
6
Sent from Yandex Bot
WordType
Used to provide context over where the text we wish to translate comes from. Any general text node is of WordType 1. We use the WordType to classify translations on the admin dashboard.
{
"l_from":"en",
"l_to":"fr",
"title":"My awesome page",
"request_url":"https:\/\/www.website.com\/",
"bot":0,
"from_words":[
"This is a blue car",
"This is a black car"
],
"to_words":[
"C'est une voiture bleue",
"C'est une voiture noire"
]
}
POST /translate?api_key=my_api_key HTTP/1.1
Host: api.weglot.com
Content-Type: application/json
{
"l_from":"en",
"l_to":"fr",
"request_url":"https://www.website.com/",
"words":[
{"w":"This is a blue car", "t": 1},
{"w":"This is a black car", "t": 1}
]
}
curl -X POST \
'https://api.weglot.com/translate?api_key=my_api_key' \
-H 'Content-Type: application/json' \
-d '{
"l_from":"en",
"l_to":"fr",
"request_url":"https://www.website.com/",
"words":[
{"w":"This is a blue car", "t": 1},
{"w":"This is a black car", "t": 1}
]
}'