Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WordnikAPI

Defines the WordnikAPI class.

Hierarchy

  • WordnikAPI

Index

Constructors

  • Constructs a new WordnikAPI instance.

    Parameters

    • API_KEY: string

      The API key to use.

    Returns WordnikAPI

Properties

API_KEY: string
BASE_URL: "https://api.wordnik.com/v4/word.json/" = "https://api.wordnik.com/v4/word.json/"
WORDS_URL: "https://api.wordnik.com/v4/words.json/" = "https://api.wordnik.com/v4/words.json/"

Methods

  • getAPIKey(): string
  • getAudio(word: string, useCanonical?: boolean, limit?: number): Promise<null | AudioMetadata[]>
  • Get the audio metadata for a word.

    Parameters

    • word: string

      The word to get audio metadata for.

    • useCanonical: boolean = false

      Whether to use the canonical form of the word (e.g. "cats" -> "cat").

    • limit: number = 1

      The limit of audio metadata to get.

    Returns Promise<null | AudioMetadata[]>

    The audio metadata for the word, or null if the word is not found.

  • getDefinitions(word: string, limit?: number, partOfSpeech?: undefined | PartOfSpeech | PartOfSpeech[], sourceDictionary?: "all" | "ahd-5" | "century" | "wiktionary" | "webster" | "wordnet", useCanonical?: boolean, includeTags?: boolean): Promise<null | Word[]>
  • Parameters

    • word: string

      The word to get definitions for.

    • limit: number = 1

      The limit of definitions to get.

    • partOfSpeech: undefined | PartOfSpeech | PartOfSpeech[] = undefined

      The part of speech to get definitions for.

    • sourceDictionary: "all" | "ahd-5" | "century" | "wiktionary" | "webster" | "wordnet" = "all"

      The source dictionary to get definitions for.

    • useCanonical: boolean = false

      Whether to use the canonical form of the word (e.g. "cats" -> "cat").

    • includeTags: boolean = false

      Whether to include tags in the response.

    Returns Promise<null | Word[]>

    The definitions for the word, or null if the word is not found.

  • getEtymologies(word: string, useCanonical?: boolean): Promise<null | string[]>
  • Parameters

    • word: string

      The word to get etymologies for.

    • useCanonical: boolean = false

      Whether to use the canonical form of the word (e.g. "cats" -> "cat").

    Returns Promise<null | string[]>

    The etymologies for the word, or null if the word is not found.

  • getExamples(word: string, includeDuplicates?: boolean, useCanonical?: boolean, skip?: number, limit?: number): Promise<null | Example[]>
  • Parameters

    • word: string

      The word to get examples for.

    • includeDuplicates: boolean = false

      Whether to include duplicate examples.

    • useCanonical: boolean = false

      Whether to use the canonical form of the word (e.g. "cats" -> "cat").

    • skip: number = 0

      The number of examples to skip.

    • limit: number = 1

      The limit of examples to get (max 50).

    Returns Promise<null | Example[]>

    The examples for the word, or null if the word is not found.

  • getFrequency(word: string, useCanonical?: boolean, startYear?: number, endYear?: number): Promise<null | Frequency[]>
  • Parameters

    • word: string

      The word to get the frequency of.

    • useCanonical: boolean = false

      Whether to use the canonical form of the word (e.g. "cats" -> "cat").

    • startYear: number = 1800

      The start year to get the frequency of.

    • endYear: number = 2012

      The end year to get the frequency of.

    Returns Promise<null | Frequency[]>

    The frequency of the word, or null if the word is not found.

  • getHyphenation(word: string, useCanonical?: boolean, sourceDictionary?: "all" | "ahd-5" | "century" | "wiktionary" | "webster" | "wordnet", limit?: number): Promise<null | Syllable[]>
  • Parameters

    • word: string

      The word to get the hyphenation of.

    • useCanonical: boolean = false

      Whether to use the canonical form of the word (e.g. "cats" -> "cat").

    • sourceDictionary: "all" | "ahd-5" | "century" | "wiktionary" | "webster" | "wordnet" = "all"

      The source dictionary to get the hyphenation of.

    • limit: number = 1

      The limit of hyphenations to get.

    Returns Promise<null | Syllable[]>

    The word's hyphenation.

  • getPhrases(word: string, useCanonical?: boolean, limit?: number): Promise<null | Phrase[]>
  • getPronunciation(word: string, useCanonical?: boolean, sourceDictionary?: undefined | "ahd-5" | "century" | "wiktionary" | "webster" | "wordnet", typeFormat?: undefined | "ahd-5" | "arpabet" | "gcide-diacritical" | "IPA", limit?: number): Promise<null | Pronunciation[]>
  • Parameters

    • word: string

      The word to get the pronunciation of.

    • useCanonical: boolean = false

      Whether to use the canonical form of the word (e.g. "cats" -> "cat").

    • sourceDictionary: undefined | "ahd-5" | "century" | "wiktionary" | "webster" | "wordnet" = undefined

      The source dictionary to get the pronunciation of.

    • typeFormat: undefined | "ahd-5" | "arpabet" | "gcide-diacritical" | "IPA" = undefined

      The type of pronunciation to get.

    • limit: number = 1

      The limit of pronunciations to get.

    Returns Promise<null | Pronunciation[]>

    The word's Pronunciation.

  • getRandomWord(hasDictionaryDef?: "true" | "false", includePartOfSpeech?: undefined | PartOfSpeech, excludePartOfSpeech?: undefined | PartOfSpeech, minCorpusCount?: undefined | number, maxCorpusCount?: undefined | number, minDictionaryCount?: undefined | number, maxDictionaryCount?: undefined | number, minLength?: undefined | number, maxLength?: undefined | number): Promise<null | RandomWord>
  • Parameters

    • hasDictionaryDef: "true" | "false" = "true"

      Only return words with dictionary definitions

    • includePartOfSpeech: undefined | PartOfSpeech = undefined

      Only return words with the specified part of speech.

    • excludePartOfSpeech: undefined | PartOfSpeech = undefined

      Only return words without the specified part of speech.

    • minCorpusCount: undefined | number = undefined

      Minimum corpus frequency for terms

    • maxCorpusCount: undefined | number = undefined

      Maximum corpus frequency for terms

    • minDictionaryCount: undefined | number = undefined

      Minimum dictionary count

    • maxDictionaryCount: undefined | number = undefined

      Maximum dictionary count

    • minLength: undefined | number = undefined

      Minimum word length

    • maxLength: undefined | number = undefined

      Maximum word length

    Returns Promise<null | RandomWord>

  • getRandomWords(hasDictionaryDef?: "true" | "false", includePartOfSpeech?: undefined | PartOfSpeech[], excludePartOfSpeech?: undefined | PartOfSpeech[], minCorpusCount?: undefined | number, maxCorpusCount?: undefined | number, minDictionaryCount?: undefined | number, maxDictionaryCount?: undefined | number, minLength?: undefined | number, maxLength?: undefined | number, sortBy?: undefined | "alpha" | "count", sortOrder?: undefined | "asc" | "desc", limit?: number): Promise<RandomWord[]>
  • Parameters

    • hasDictionaryDef: "true" | "false" = "true"

      Only return words with dictionary definitions

    • includePartOfSpeech: undefined | PartOfSpeech[] = undefined

      Only return words with the specified part of speech.

    • excludePartOfSpeech: undefined | PartOfSpeech[] = undefined

      Only return words without the specified part of speech.

    • minCorpusCount: undefined | number = undefined

      Minimum corpus frequency for terms

    • maxCorpusCount: undefined | number = undefined

      Maximum corpus frequency for terms

    • minDictionaryCount: undefined | number = undefined

      Minimum dictionary count

    • maxDictionaryCount: undefined | number = undefined

      Maximum dictionary count

    • minLength: undefined | number = undefined

      Minimum word length

    • maxLength: undefined | number = undefined

      Maximum word length

    • sortBy: undefined | "alpha" | "count" = undefined

      Sort by

    • sortOrder: undefined | "asc" | "desc" = undefined

      Sort order

    • limit: number = 10

      Limit

    Returns Promise<RandomWord[]>

    Random words, or an empty array if no words were found.

  • getRelatedWords(word: string, useCanonical?: boolean, relationshipTypes?: undefined | RelationshipType, limitPerRelationshipType?: undefined | number): Promise<null | RelatedWord[]>
  • Parameters

    • word: string

      The word to get related words for.

    • useCanonical: boolean = false

      Whether to use the canonical form of the word (e.g. "cats" -> "cat").

    • relationshipTypes: undefined | RelationshipType = undefined

      The relationship types to get.

    • limitPerRelationshipType: undefined | number = undefined

      The limit of related words to get per relationship type.

    Returns Promise<null | RelatedWord[]>

    The related words or null if an error occurred.

  • getScrabbleScore(word: string): Promise<null | number>
  • getTopExample(word: string, useCanonical?: boolean): Promise<null | Example>
  • getWordOfTheDay(date?: undefined | string | Date): Promise<null | WordOfTheDay>
  • makeRequest(endpoint: string, params: any, base_url?: string): Promise<any>
  • Make an API call to the Wordnik API.

    Parameters

    • endpoint: string

      The endpoint to call.

    • params: any

      The parameters to pass to the endpoint.

    • base_url: string = WordnikAPI.BASE_URL

      The base URL to use (optional).

    Returns Promise<any>

Generated using TypeDoc