vocaDB API is a paid service. Check our Pricing for detailed information.
This document explains common features of Extraction API using the RESTful style.
Extraction API is one of vocaDB Dictionary APIs and provides extracted words and idioms list results by user's English level from searched text/sentence input.
What is the difference between dictionary APIs and Extraction API?
Extraction API
services sentence search.
Dictionary APIs service four input types such as a word, idiom, non-English word and sentence(s).
You can search a 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_dic_tooltip_text.php
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"=> 'Valuable clients can read and learn translated docs with audio anytime, anywhere.', "level"=> 21, "direction"=>0 ); //Convert $params into POST-ready foreach($params as $key=>$value) { $data_string .= $key.'='.$value.'&'; } //remove extra & in params $data_string = rtrim($data_string, '&'); //Check if the searched word has space or not. if($this->input->post('space_cnt') > 0) { $link = Simple_word_API_path; } else { $link = Extraction_text_API_path; } $ch = curl_init( $link ); 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 data properties in JSON:
{ "type": 4 "contents": { "trans": { "count": 4, /* Inputed total words */ "letters": 27 }, "words": { "relative_words": [ { "voca": "crisis", "ilevel": "23", "part": "명", "means": "1. 위기 2. 중대 국면, 고비 (=crises)", "level": "중3", "audio": "crisis", "origin": "crisis" }, { "voca": "financial", "ilevel": "23", "part": "형", "means": "재정의, 자금의", "level": "중3", "audio": "financial", "origin": "financial" } ] } "newwords": 0, "idioms": { "relative_idioms": [ { "idiom": "financial crisis", "ilevel": "23", "level": "중3", "means": "금융 위기", "audio": "financial crisis", "origin": "financial crisis" } ] } } }
All required parameters for Extraction API are summarized in the following table.
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 } | |
d |
|
{ 0 | 1 } |
Landscape or PC : 0 Portrait or Mobile : 1 |
Apikey | Parameter | Value | Comments |
---|---|---|---|
apikey |
apikey | Oauth | 32 characters |
API keys are available once you Apply for API.
Note:
At least one (1) of the languages (Source language slang
or Target language tlang
) must be in English (en
) for the request to work.
Cases | Example | Value | Comments |
---|---|---|---|
sentence(s) | The financial crisis is considered by many economists to be the worst financial crisis | English | limit 500 letters depend on the price |
Returned JSON format :
{ "type": {-1 | 0 | 1 | 2 | 3 | 4} , "contents": { 0 | -1 | -2 | -3 | [words] | [idioms] } }
The result consists of type and content parts.
Example, {"type":4,"contents":0} the content parts of words have four sub contents which are words, idioms, notfound and new_words.
Value of Type | Meaning | Comments |
---|---|---|
-1 | Illegal Access | Access authority |
0 | No result | Wrong Values |
1 | for a normal word | { [words] } |
2 | for an idiom | { [idioms] } |
3 | for non-English | Not available now |
4 | Extraction for sentence(s) | 4 Groups : trans, [words], [idioms], and newwords |
[words] consists [{words items}] | [relative_words] | [idioms] consists [{idioms items}] | [relative_idioms] |
Value of Contents | Format | Comments |
---|---|---|
-1 | {"type":-1,"contents":-1} | Wrong APIkey |
-2 | {"type":-1,"contents":-2} | Expired Apikey |
-3 | {"type":-1,"contents":-3} | Parameters Error |
-5 | {"type":-1,"contents":-5} | Suspected hacking query |
-10 | {"type":-1,"contents":-10} | Access denied |
Value of Contents | Format | Comments |
---|---|---|
0 | {"type":0,"contents":0} | No result |
-1 | {"type":0,"contents":-1} | Access Error |
-1 | {"type":3,"contents":-1} | The search word is Non-English for examples - "성공", "する" |
-2 | {"type":3,"contents":-2} | Non-English word's length must have minimum 6 bytes (2 letters) for example, 눈 or 捕 |
-3 | {"type":3,"contents":-3} | a restricted word of input word in non-English, Korean for examples - "이다", "する" |
Type | Contents | Comments |
---|---|---|
4 |
{ "type": 4 "contents": { "trans": { "count": 78, "letters": 378 }, "words": { "relative_words": [] }, "newwords": , /* Newwords mean there have not existed words in vocaDB dictionary. */ "idioms": { "relative_idioms": [] } } |
Count is the number of word(s) found Letters are the number of letters counted |