"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to use Free dictionary API

How to use Free dictionary API

Published on 2024-11-08
Browse:951

How to use Free dictionary API

Cover photo by Christopher Gower on Unsplash

Are you developing a language learning app, a writing assistant, or any project involving words and need an API to retrieve word meanings? Free Dictionary API offers a free and accessible way to incorporate language data into your work. This documentation will show you how to get started.

In this API documentation:

  • About Free dictionary API
  • Endpoint
  • Examples
  • Additional Resources

About Free dictionary API:

Free Dictionary API developed by meetDeveloper and has 2.6k stars on GitHub. API supports only GET requests and provides word definitions along with phonetic transcriptions.

Key Features:

  • Free to use
  • No usage limits
  • No authorization or API keys required

Endpoint

https://api.dictionaryapi.dev/api/v2/entries/en/
  • This endpoint retrieves dictionary information for the specified English word.

  • The API has two versions: v1 and v2. The primary difference lies in the response structure. Current version is v2.

Query Parameters

  • word (string, required): The word you want to look up.

Response Format

The API returns a JSON array containing a single object with detailed information about the word, including:

If the request is successful:

  • word(string): The queried word
  • phonetic(string): The phonetic transcription of the word
  • phonetics(array): An array of phonetic objects, each with:
  • text(string): The phonetic transcription
  • audio(string): A URL to an audio pronunciation (may be empty)
  • meanings(array): An array of objects representing meanings
  • partOfSpeech (string): The part of speech (e.g., noun, verb)
  • definitions (array): An array of definition objects, each with:
  • definition (string): The definition of the word
  • synonyms(array): An array of synonyms
  • antonyms (array): An array of antonyms
  • license(object): Information about the license under which the data is provided
  • sourceUrls (array): An array of URLs to the sources of the data

If the request is not successful:

  • title (string): A message indicating that no definitions were found for the word
  • message (string): Message that the definitions for the word was not found
  • resolution(string): Suggestion to use search again or web.

Examples:

Example Request 1 (successful):

const word = "documentation";
fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`)
  .then(response => response.json())
  .then(data => console.log(data));

Example Response 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"
    ]
  }
]

Example Request 2 :

const word = "Software engineer";
fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`)
  .then(response => response.json())
  .then(data => console.log(data));

Example Response 2 (not successful):

{
  "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."
}

Success and Error Codes

This API does not currently return specific success or error codes.

Additional Resources

To try the API or support the Free Dictionary API, go to Free Dictionary API website.

See also Free Dictionary API project on Github.

Release Statement This article is reproduced at: https://dev.to/trushmi/how-to-use-free-dictionary-api-gec?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3