Skip to content

πŸ¦„ An initiative to create a dictionary which is free for everyone πŸš€

License

Notifications You must be signed in to change notification settings

vighnesh153/open-dictionary

Repository files navigation

🐢 Open Dictionary πŸ¦„

Total words count GitHub last commit GitHub commit activity GitHub contributors GitHub watchers GitHub Repo stars GitHub forks License

Introduction

A free simple-to-use English dictionary for everyone.

How to use?

1. πŸš€ GitHub URL (RECOMMENDED)

  • Break your word into single letters and create a /-separated path
  • Prefix the path with https://raw.githubusercontent.com/vighnesh153/open-dictionary/main/data/
  • Suffix the path with /_.json

Example

For fetching the definition of apple

https://raw.githubusercontent.com/vighnesh153/open-dictionary/main/data/a/p/p/l/e/_.json

2. πŸ› οΈ My custom Cloudflare worker (for quick testing)

Pass your word to this url as a search parameter: open-dictionary.vighnesh153.workers.dev?word=<your-word>

In this, behind the scenes, I just build the GitHub URL from the approach mentioned above

Examples

Note: This approach is not recommended because this worker has a free limit of 100K requests per day. If a lot of people are using this, then your application might hit a downtime if the threshold is breached

3. ❌ Build your own URL builder

You can build your own Cloudflare worker or AWS Lambda that builds the URL for you.

But why would you do this? Using approach 1 is not that difficult. It just contains a couple of string manipulation steps.

List of all words

Find all the words here: metadata/all-words.txt

Why does this exist? πŸ§‘πŸΌβ€πŸ’»

  • No other free API for getting English definitions of a word
  • No other trusted source for fetching definitions as an API
  • No reliable (in terms of uptime and rate limiting) server

How does this solve the above-mentioned problems? πŸ—οΈ

  • This is a free repository. You don't need to pay a single penny for using this. Although you are welcome to sponsor this project if you are interested πŸ™Œ
  • This repository is trustworthy because everyone can see the word definitions as code. This offers transparency and trust for developers.
  • GitHub's servers are more reliable than a custom server managed by a small group of people without any funding

Word missing or something doesn't match Wiktionary's page? πŸ₯Ή

Found a word which is not available in this repository? Or, some definition is not matching Wiktionary's page for the word? It is possible that Wiktionary might have updated the definition for the word. Since this repo doesn't listen to changes in Wiktionary, the definitions don't get synced in this repo automatically and will need a manual update trigger.

  • Create an issue specifying which word is missing or doesn't match Wiktionary's information
  • It would be more awesome if you could also raise a PR for the issue (Creating a PR is easy. You just need to run the script specified in the Contributions section and verify if the JSON is correct)

Checkout the Contributions section.

Where do I source my data from? πŸ₯·πŸ»

A simple search on wiktionary. For example:

Type Definition (API Contract) βš–οΈ

The json files will have a type of WordWiki described below:

interface WordWiki {
    word: string;
    etymologies: Array<Etymology>;
}

interface Etymology {
    description: Array<string>;
    nouns: Array<PartOfSpeech>;
    verbs: Array<PartOfSpeech>;
    adjectives: Array<PartOfSpeech>;
    prepositions: Array<PartOfSpeech>;
    adverbs: Array<PartOfSpeech>;
    letter: Array<PartOfSpeech>;
    number: Array<PartOfSpeech>;
}

interface PartOfSpeech {
    description: string;
    definitionGroups: Array<DefinitionGroup>;
}

interface DefinitionGroup {
    description: string;
    entries: Array<{
        meaning: string;
        examples: Array<string>;
    }>;
}

Contributions ❀️

Checkout the Contributions guide

FAQs 🐷

https://dictionaryapi.dev/ is an excellent tool for getting the word definitions. It has a few drawbacks though:

  • It is hosted on the author's server which is not reliable. Lot of people have reported it being unavailable or getting rate limit throttled
  • Author makes use of undocumented Google API to fetch the definition and the Google API looks very fragile. If Google decides to change the output, the Author's API will break or return malformed response.