DEV Community

Cover image for How to use Free dictionary API
Iryna Trush
Iryna Trush

Posted on • Edited on

How to use Free dictionary API

Cover photo by Christopher Gower on Unsplash

Need to add word definitions or language features to your project? The Free Dictionary API is a powerful and easy-to-use tool that can help! The API facilitates the retrieval of lexical information for English words, including definitions, phonetic transcriptions, and related data.

In this API documentation:

Overview:

Developed by meetDeveloper and reaching 2.6k stars on GitHub, the Free Dictionary API offers a simple way to integrate dictionary data into your applications.

Note: API supports only GET requests.

Key Features:

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

Endpoint

https://api.dictionaryapi.dev/api/v2/entries/en/<word>
Enter fullscreen mode Exit fullscreen mode
  • 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 different meanings of the word, each with:
    • 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));
Enter fullscreen mode Exit fullscreen mode

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"
    ]
  }
]
Enter fullscreen mode Exit fullscreen mode

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));
Enter fullscreen mode Exit fullscreen mode

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."
}
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)