
unsplash 上的封面照片由 christopher gower
您是否正在开发语言学习应用程序、写作助手或任何涉及单词并需要 api 来检索单词含义的项目?免费词典 api 提供了一种免费且易于访问的方式,将语言数据合并到您的作品中。本文档将向您展示如何开始。
在此 api 文档中:
关于免费词典 api端点示例其他资源
关于免费词典 api:
由 meetdeveloper 开发的免费词典 api,在 github 上拥有 2.6k star。 api 仅支持 get 请求,并提供单词定义和音标。
主要特点:
免费使用无使用限制无需授权或 api 密钥
端点
https://api.dictionaryapi.dev/api/v2/entries/en/
此端点检索指定英文单词的字典信息。
api 有两个版本:v1 和 v2。主要区别在于响应结构。当前版本是 v2。
免费语音克隆
这是一个提供免费语音克隆服务的平台,用户只需上传或录制一段 5 秒以上的清晰语音样本,平台即可生成与用户声音高度一致的 AI 语音克隆。
95 查看详情
查询参数
单词(字符串,必需):您要查找的单词。
响应格式
api 返回一个 json 数组,其中包含单个对象,其中包含有关单词的详细信息,包括:
如果请求成功:
word(string): 查询的单词voicetic(string): 单词的音标voicetics(array): 语音对象数组,每个对象包含:text(string): 音标audio(string): 音频发音的 url(可能为空)含义(数组):表示含义的对象数组partofspeech(字符串):词性(例如名词、动词)定义(数组):定义对象的数组,每个对象包含:定义(字符串):单词的定义synonyms(array): 同义词数组antonyms (array): 反义词数组许可证(对象):有关提供数据的许可证的信息sourceurls (array): 数据源的 url 数组
如果请求不成功:
title (string): 一条消息,表明没有找到单词的定义message(字符串):未找到该单词的定义的消息解决方案(字符串):建议再次使用搜索或网络。
示例:
请求示例 1(成功):
const word = "documentation";fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`) .then(response => response.json()) .then(data => console.log(data));
响应示例 1:
[ { "word": "documentation", "phonetic": "/ˌdɒkjʊmənˈteɪʃən/", "phonetics": [ { "text": "/ˌdɒkjʊmənˈteɪʃən/", "audio": "" }, { "text": "/ˌdɑkjəmənˈteɪʃən/", "audio": "" } ], "meanings": [ { "partofspeech": "noun", "definitions": [ { "definition": "something transposed from a thought to a document; the written account of an idea.", "synonyms": [], "antonyms": [] }, { "definition": "documentary evidence and sources.", "synonyms": [], "antonyms": [] }, { "definition": "documents that explain the operation of a particular machine or software program.", "synonyms": [], "antonyms": [] }, { "definition": "comments that explain the usage of individual functions, libraries and blocks of code.", "synonyms": [], "antonyms": [] } ], "synonyms": [], "antonyms": [] } ], "license": { "name": "cc by-sa 3.0", "url": "https://creativecommons.org/licenses/by-sa/3.0" }, "sourceurls": [ "https://en.wiktionary.org/wiki/documentation" ] }]
请求示例 2:
const word = "software engineer";fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`) .then(response => response.json()) .then(data => console.log(data));
响应示例 2(未成功):
{ "title": "No Definitions Found", "message": "Sorry pal, we couldn't find definitions for the word you were looking for.", "resolution": "You can try the search again at later time or head to the web instead."}
成功和错误代码
此 api 目前不返回特定的成功或错误代码。
其他资源
要尝试该 api 或支持 free dictionary api,请访问 free dictionary api 网站。
另请参阅 github 上的免费词典 api 项目。
以上就是如何使用免费词典API的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/451010.html
微信扫一扫
支付宝扫一扫