Translation API

This API is not available since 2021.1.

Introduction

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:

Source language
  > Use the slang query parameter to specify the source language.
Target language
  > Use the tlang query parameter to specify the target language.
Search word or text string
  > Use the q query parameter to identify the string to be translated.
User's Level for extract
  > Use the engin query parameter to identify the translation engine which is MS Bing or Google translator.
Direction or Device
  > Use the d query parameter to inform on direction or device.

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 );
Adding your API key in Header
//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

Input Text must have UTF-8 code.

header('Content-Type: application/plain; charset=UTF-8');

Query parameter reference

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
  • Source language
Language reference
tlang
  • Target language
Language reference
level
  • User's English level
{ 1 | 9 | 13 | 21 | 22 | 23 | 31 | 32 | 33 | 41 }
engin
  • Translator Engine
{ 0 | 1 } MS Bing : 0
Google : 1
d
  • Direction or Device
{ 0 | 1 } Landscape or PC : 0

MS Bing does not support the follow languages
Armenian - 'hy', Filipino - 'tl', Georgian - 'ka', Tamil - 'ta'


Translated result

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


Illegal Reference


  • Example Error Code : 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'
    Apply it Apply for APIs right now