This document is intended for developers who want to write applications that can interact with the Translation API.
With vocaDB Dictionary or Tooltip, you can programmatically extract words or translate text from input in your webpages or apps.
The result of a request from Translation API is plain text.
Translated text made by MS bing or Google translator.
You can translate word from one language to another by sending an HTTP POST
request to its URL.
The URL for a request has the following format:
https://vocabdb.com/v2_dic/api_translation.php
Five query parameters are required with each search request:
Important!
You need to include in a custom header named x-voca-apikey
, along with your API key.
Example of PHP curl
$params = array( "slang" => 'en', "tlang"=> 'ko', "q"=> 'We serve extracted words, idioms list and translated documentation with any language', "engin"=>0, "d"=>0 ); //Convert $params into POST-ready foreach($params as $key=>$value) { $data_string .= $key.'='.$value.'&'; } //remove extra & in params $data_string = rtrim($data_string, '&'); //link to VocaDB API $ch = curl_init( "https://vocabdb.com/v2_dic/api_translation.php" ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $data_string );
//set header and apikey
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
'x-voca-apikey: INSERT-YOUR-KEY',
'charset=UTF-8')
);
$result_api = curl_exec($ch);
curl_close($ch);
If the request succeeds, the server responds with a 200 OK
HTTP status code and the translated text in string
header('Content-Type: application/plain; charset=UTF-8');
Parameter | Meaning | Value | Usage/Sample |
---|---|---|---|
APIkey |
Your API key | 32 unique characters |
Users must include them in a custom header x-voca-apikey
|
q |
search words & sentence(s) | The text to be searched or extracted word list. | arrest |
slang |
|
Language reference | |
tlang |
|
Language reference | |
level |
|
{ 1 | 9 | 13 | 21 | 22 | 23 | 31 | 32 | 33 | 41 } | |
engin |
|
{ 0 | 1 } |
MS Bing : 0 Google : 1 |
d |
|
{ 0 | 1 } |
Landscape or PC : 0 |
MS Bing does not support the follow languages
Armenian - 'hy',
Filipino - 'tl',
Georgian - 'ka',
Tamil - 'ta'
Example query | Return Value | Comments |
---|---|---|
q = 체포 slang = en tlang = zh-CN |
逮捕 | Success |
q = Success slang = en tlang = ja |
成功 | Success |
q = 체포 slang = en tlang = ko |
arrest | Success |
q = arrest slang = tlang = ko |
null | Missing Parameters |
q = arrest slang = en tlang = en |
Error Same Language : en | Both languages are same. |
q = The late-2000s financial crisis is considered by many economists to be the worst financial crisis since the Great Depression of the 1930s.
slang = en tlang = ko |
2000 년대 후반 금융 위기는 1930 년대의 대공황 이후 최악의 금융 위기를 수 많은 경제 학자에 의해 간주 됩니다. | Plain text |
Message | Comments |
---|---|
No Access authority | Error APIkey |
Error Parameter | Wrong parameter |
Error Same Language | Both languages are same. |
MS Bing | MS Bing does not support this language for translation like Armenian - 'hy', Filipino - 'tl', Georgian - 'ka', Tamil - 'ta' |