> You can skip this if hou already know the language code
.
curl --request GET \
--url https://english-word-translator-api.p.rapidapi.com/languages \
--header 'X-RapidAPI-Key: Your-API-Key'
It will return following JSON:
[
{
"code": "af",
"name": "Afrikaans",
"nativeName": "Afrikaans"
},
{
"code": "ar",
"name": "Arabic",
"nativeName": "العربية"
},
// more languages
{
"code": "zh-Hans",
"name": "Chinese Simplified",
"nativeName": "中文 (简体)"
}
]
The value of code
column is the target language we will use.
curl --request GET \
--url 'https://english-word-translator-api.p.rapidapi.com/translate?text=apple&to_lang=ar' \
--header 'X-RapidAPI-Key: Your-API-Key'
We need to pass 2 parameters:
text
: The word to translate.to_lang
: The target language, which should be the language code
from Step 1.This will response:
{
"word": "apple",
"language": "ar",
"proficiency": "A1",
"pronunciations": [
{
"id": "af3ece18c8ad5f84",
"pronunciation": "/ˈæpl/",
"accent": "UK",
"hasAudio": true
},
{
"id": "af3ece18c8ad5f85",
"pronunciation": "/ˈæpl/",
"accent": "US",
"hasAudio": true
}
],
"translations": [
{
"translation": "ابل",
"confidence": 0.3298,
"posTag": "NOUN"
},
// more translations
]
}
curl --request GET \
--url 'https://english-word-translator-api.p.rapidapi.com/audio?pronunciation_id=the_pronunciation_id' \
--header 'X-RapidAPI-Key: Your-API-Key'
We need pass 1
parameter:
pronunciation_id
: The pronunciation id
from Step 2.This will response a stream that can be embedded to you code or download it as mp3.