A simple API for Cambridge Dictionary, built with Node.js.
-
Thank Cambridge Dictionary nicely compiling the words.
The API entries contain dictionary option, deciding which the dictionary database to use:Dictionary Database en
English (US) uk
English (UK) en-cn
English-Chinese-Simplified en-tw
English-Chinese-Traditional -
You have to remember to encode the query by yourself. A common use is:
encodeURIComponent('cook eggs') // -> cook%20eggs
-
By default, you will get some pronunciation audios in url (ending with .mp3).
But sometimes you need the audio data.
You can append the api with?b
ot?b64
to get the base64 texts instead of audio urls.
⚠️ Note: base64 text will significantly increase the data size of the response. -
I have deployed a service you can use it for free:
🔗 https://cam-dict.ping1service.top -
This repository is built and enhanced based on Elias's work
❤️ Let's thank Elias!
/api/dictionary/`{dictionary}`/`{word}`
/api/suggest/`{dictionary}`/`{word}`
npm install
npm run dev
Then fetch http://localhost:3000/api/dictionary/en/hello
to test it
or use / to test it out with UI.
/api/dictionary/en-tw
/cook
{
"word": "cook",
"pos": ["verb", "noun"],
"verbs": [
{
"type": "Plain form",
"text": "cook"
},
{
"type": "Third-person singular",
"text": "cooks"
},
...
],
"pronunciation": [
{
"pos": "verb",
"lang": "uk",
"url": "https://dictionary.cambridge.org/us/media/english-chinese-simplified/uk_pron/u/ukc/ukcon/ukconve028.mp3",
"url": "data:audio/mpeg;base64,AAAAA......"
},
{
"pos": "verb",
"lang": "us",
"url": "https://dictionary.cambridge.org/us/media/english-chinese-simplified/us_pron/c/coo/cook_/cook.mp3"
"url": "data:audio/mpeg;base64,AAAAA......"
},
...
],
"definition": [
{
"id": 0,
"pos": "verb",
"text": "When you cook food, you prepare it to be eaten by heating it in a particular way, such as baking or boiling, and when food cooks, it is heated until it is ready to eat.",
"translation": "做飯,烹調;燒,煮",
"example": [
{
"id": 0,
"text": "I don't cook meat very often.",
"translation": "我不常煮肉吃。"
},
...
]
},
...
]
}
/api/suggest/en-cn
/cook
[
"cook",
"Cook Islander",
"cook someone’s goose",
"cook something up",
"cook the books",
"cook up, dance up, talk up, etc. a storm",
"cookbook",
"cooked",
"cooked breakfast",
"cooked/done to a turn"
]