Getting to know the Wordnik API

The Wordnik API allows developers to explore the entire English language, with a vast array of resources including dictionaries, thesauri, and example sentences. With a variety of endpoints to query, developers can gain insight into the meaning and usage of millions of words, idioms, and phrases.

Basic Usage

In order to use the Wordnik API, developers are required to sign up for an API key, which can be obtained at http://developer.wordnik.com/signup/. Once you have your key, you can start making requests to the API.

Endpoint: /word.json/{word}

The /word.json/{word} endpoint returns basic information about a particular word, including its definition(s), part(s) of speech, and example sentences. Here's how you can make a request to this endpoint:

const request = require('request');

const options = {
  url: 'http://api.wordnik.com/v4/word.json/test?api_key=YOUR_API_KEY',
  json: true
};

request.get(options, (error, response, body) => {
  if (error) {
    console.error(error);
  } else {
    console.log(body);
  }
});

Note that you'll need to replace YOUR_API_KEY with your actual API key.

Endpoint: /word.json/{word}/pronunciations

The /word.json/{word}/pronunciations endpoint returns an array of pronunciations for a given word. Here's an example of how to use this endpoint:

const request = require('request');

const options = {
  url: 'http://api.wordnik.com/v4/word.json/test/pronunciations?api_key=YOUR_API_KEY',
  json: true
};

request.get(options, (error, response, body) => {
  if (error) {
    console.error(error);
  } else {
    console.log(body);
  }
});

Endpoint: /word.json/{word}/definitions

The /word.json/{word}/definitions endpoint returns an array of definitions for a specified word. Here's how you can use this endpoint:

const request = require('request');

const options = {
  url: 'http://api.wordnik.com/v4/word.json/test/definitions?api_key=YOUR_API_KEY',
  json: true
};

request.get(options, (error, response, body) => {
  if (error) {
    console.error(error);
  } else {
    console.log(body);
  }
});

Endpoint: /words.json/search/{query}

The /words.json/search/{query} endpoint allows developers to search for words based on a given query. This can be useful when building a type-ahead feature for an application. Here's an example of how to use this endpoint:

const request = require('request');

const query = 'test';
const options = {
  url: `http://api.wordnik.com/v4/words.json/search/${query}?api_key=YOUR_API_KEY`,
  json: true
};

request.get(options, (error, response, body) => {
  if (error) {
    console.error(error);
  } else {
    console.log(body);
  }
});

Conclusion

The Wordnik API provides a rich set of resources for developers looking to build language-focused applications. Whether you're building a dictionary app, a game that involves wordplay, or anything in between, the Wordnik API can be a powerful tool in your arsenal.

Related APIs

Public APIs — A directory of free and public apis

Built by @mddanishyusuf