Hangulize provides a web API for non-python projects. So any project which could parse a JSON or plist string can use the features of Hangulize.
Note
If your project is written in Python, don’t use the web API. The native Hangulize module is faster than it.
To use the web API, we should send a HTTP request to www.hangulize.org. all methods of the web API send different results in different Accept or Accept-Language HTTP headers. So we should send a them to the web API.
For example, if we want to get the supported language list of Hangulize with Korean (ko) labels, then we should request such as:
$ curl 'http://www.hangulize.org/langs' \
> -H'Accept: application/json' \
> -H'Accept-Language: ko'
GET /langs HTTP/1.1
Host: www.hangulize.org
Accept: application/json
Accept-Languages: ko
In this case, the response is:
{
"length": 38,
"langs": [
{
"code": "aze",
"name": "Azerbaijani",
"label": "\uc544\uc81c\ub974\ubc14\uc774\uc794\uc5b4",
"iso639-1": "az",
"iso639-2": "aze",
"iso639-3": "aze"
},
...
{
"code": "wlm",
"iso639-3": "wlm",
"name": "MiddleWelsh",
"label": "\uc6e8\uc77c\uc2a4\uc5b4(\uc911\uc138)"
}
],
"success": true
}
Look the structure and a "label" property of an item in "langs". We got the result as JSON structure, and there are Korean language labels.
To get a JSONP result, just add a jsonp parameter into the querystring. Whatever the Accept header, the web API will send JSONP data. For example:
<script>
// define a function for JSONP callback
function callbackFunction( data ) {
if ( data.success ) {
alert( "Hangulize supports " + data.length + " languages." );
} else {
throw new Error( data.reason );
}
}
</script>
<!-- call a method -->
<script src="http://www.hangulize.org/langs?jsonp=callbackFunction">
</script>
Transcribes a loanword to Hangul.
Url : | |
---|---|
Method : | GET |
Parameters: |
|
Result types: |
|
Data structure:
result | A transcription result | ||||||||||||
word | The given word | ||||||||||||
lang |
|
||||||||||||
success | true or false, when it false the result contains a reason property. | ||||||||||||
reason | An error message when success is false |
Sends a random example. If the lang parameter isn’t specified then it selects a random language also.
Url : | |
---|---|
Method : | GET |
Parameters: | lang – (optional) a specified language code |
Result types: |
|
Data structure:
result | A transcription result |
word | A selected random word |
lang | The given language or selected random language. It’s structure is same as lang in hangulize(). |
success | true or false, when it false the result contains a reason property. |
reason | An error message when success is false |
Sends the language list that Hangulize is supporting.
Url : | |
---|---|
Method : | GET |
Result types: |
|
Data structure:
length | A length of the language list |
langs | An array of the languages. The language data structure is same as lang in hangulize(). |
success | true or false, when it false the result contains a reason property. |
reason | An error message when success is false |