Static API

Use the dictionary from any static host.

The API is a collection of versioned JSON files. Apps load a tiny letter index, fetch one word index for the matching first letter, then fetch the dictionary chunk that contains the entry.

Base URL

Local development:

http://localhost:8000/api/v1/

GitHub Pages:

https://shubhamnpk.github.io/yoshabdakosh/api/v1/

Lookup flow

const baseUrl = "https://shubhamnpk.github.io/yoshabdakosh/api/v1";
const query = "अ".normalize("NFC");
const firstLetter = Array.from(query)[0];

const letters = await fetch(`${baseUrl}/letters.json`).then((r) => r.json());
const group = letters.letters.find((item) => item.letter === firstLetter);

const wordIndex = await fetch(`${baseUrl}/${encodeURI(group.path)}`).then((r) => r.json());
const match = wordIndex.words.find((item) => item.word === query);

const chunk = await fetch(`${baseUrl}/${match.path}`).then((r) => r.json());
const entry = chunk.entries.find((item) => item.word === query);

Response shape

{
  "word": "अ",
  "definitions": [
    {
      "grammar": "ना.",
      "etymology": "[सं.]",
      "senses": ["१. संस्कृत एकाक्षरी कोशअनुसार मूलतः विष्णुलाई जनाउने मङ्गलवाची शब्द।"]
    }
  ]
}

Regenerate files

node scripts/generate-api.mjs
node scripts/validate-data.mjs