Skip to content

Dictionary API

The Dictionary API provides access to Nepali words with definitions, parts of speech, and similar word suggestions. Search results are sourced from both Brihat Nepali Sabdakosh and Pragya Nepali Brihat Shabdakosh.

Endpoints

Method Endpoint Description
GET /api/v1/dictionary/word?q={word} Look up a word
GET /api/v1/dictionary/word/{word} Look up a word (path parameter)
GET /api/v1/dictionary/suggest?q={prefix} Get autocomplete suggestions
GET /api/v1/dictionary/related?q={word} Get orthographically related public headwords

Word Lookup

Look up a Nepali word and get its definition. By default, Sabdasakha preserves the legacy exact-match response shape. Optional query parameters enable grouped variants or per-dictionary results.

Request

GET /api/v1/dictionary/word?q={word}

or

GET /api/v1/dictionary/word/{word}
Parameter Type Required Description
q or word string Yes The Nepali word to look up (URL-encoded)
include_variants boolean No If true, return all variants grouped under the base word
multi_dict boolean No If true, return results grouped by Nepali dictionary source. This takes precedence over include_variants

Lookup Modes

Mode Query Response shape Use when
Exact lookup default WordResult You want the legacy single-entry response
Variant grouping include_variants=true WordResultWithVariants You want base words such as to return अ(१), अ(२), etc.
Multi-dictionary multi_dict=true MultiDictWordResult You want separate results from Brihat and Pragya dictionaries

Example Request

curl "https://sabdasakha.com/api/v1/dictionary/word?q=घर"
import requests

response = requests.get(
    "https://sabdasakha.com/api/v1/dictionary/word",
    params={"q": "घर"}
)
word = response.json()
print(word["definitions"])
const response = await fetch(
  "https://sabdasakha.com/api/v1/dictionary/word?q=घर"
);
const word = await response.json();
console.log(word.definitions);

Success Response (200)

{
  "word": "घर",
  "part_of_speech": null,
  "split_definitions": "[{\"number\": \"१.\", \"text\": \"गारो लगाई छानु...\", ...}]",
  "definitions": [
    {
      "number": "१.",
      "text": "गारो लगाई छानु हालेर बनाएको मानिस बस्ने ठाउँ; गृह; आलय; भवन; निकेतन; निवासस्थान; आवास।",
      "part_of_speech": null
    },
    {
      "number": "२.",
      "text": "खाना; कोठा (थर्की आदिको)।",
      "part_of_speech": null
    }
  ]
}
Field Type Description
word string The looked-up word
part_of_speech string|null Grammatical category with etymology, when available
split_definitions string JSON string of definitions (for legacy compatibility)
definitions array List of definition objects
definitions[].number string Definition number (Nepali numerals)
definitions[].text string The definition text
definitions[].part_of_speech string|null Additional POS info if different

Variant Response

Request:

curl "https://sabdasakha.com/api/v1/dictionary/word?q=अ&include_variants=true"

Response:

{
  "word": "अ",
  "has_variants": true,
  "variants": [
    {
      "variant_id": "१",
      "word": "अ(१)",
      "part_of_speech": null,
      "definitions": [
        {
          "number": "१.",
          "text": "देवनागरी वर्णमालाको स्वरवर्णमध्ये पहिलो स्वरवर्ण...",
          "part_of_speech": null
        }
      ]
    }
  ],
  "dictionary_id": "kosha-brihat",
  "dictionary_short_name": "बृहत् शब्दकोश"
}

Multi-Dictionary Response

Request:

curl "https://sabdasakha.com/api/v1/dictionary/word?q=घर&multi_dict=true"

Response:

{
  "word": "घर",
  "results": [
    {
      "dictionary_id": "kosha-brihat",
      "dictionary_name": "नेपाली बृहत् शब्दकोश",
      "dictionary_short_name": "बृहत् शब्दकोश",
      "result": {
        "word": "घर",
        "has_variants": false,
        "variants": [
          {
            "variant_id": null,
            "word": "घर",
            "part_of_speech": null,
            "definitions": [
              {
                "number": "१.",
                "text": "गारो लगाई छानु हालेर बनाएको मानिस बस्ने ठाउँ...",
                "part_of_speech": null
              }
            ]
          }
        ],
        "dictionary_id": "kosha-brihat",
        "dictionary_short_name": "बृहत् शब्दकोश"
      }
    }
  ],
  "found_in": ["kosha-brihat", "kosha-pragya"]
}

Not Found Response (404)

When a word isn't found, the API returns similar suggestions. Production responses use precomputed related-word artifacts where available and avoid request-time edit-distance scans over the full dictionary.

{
  "error": "शब्द 'घार' फेला परेन।",
  "similar_words": ["घर", "घार्नु", "घाट"]
}

Autocomplete Suggestions

Get word suggestions for search-as-you-type functionality.

Request

GET /api/v1/dictionary/suggest?q={partial_word}
Parameter Type Required Description
q string Yes Partial word to get suggestions for
limit integer No Number of suggestions (default: 10, capped at 10)
consolidate_variants boolean No If true, return base words instead of individual variant tokens

Example Request

curl "https://sabdasakha.com/api/v1/dictionary/suggest?q=नेपा"
response = requests.get(
    "https://sabdasakha.com/api/v1/dictionary/suggest",
    params={"q": "नेपा"}
)
suggestions = response.json()
const response = await fetch(
  "https://sabdasakha.com/api/v1/dictionary/suggest?q=नेपा"
);
const suggestions = await response.json();

Success Response (200)

The response is a simple array of matching words:

[
  "नेपाल",
  "नेपाल औद्योगिक विकास कर्पोरेसन",
  "नेपाल तारा",
  "नेपाल प्रज्ञा प्रतिष्ठान",
  "नेपाल प्रताप भास्कर"
]

Empty Results

If no matches are found:

[]

Get orthographically related public dictionary headwords for an existing word.

Request

GET /api/v1/dictionary/related?q={word}
Parameter Type Required Description
q string Yes Word to find related public headwords for
limit integer No Maximum number of related words (default: 10, capped at 10)
ranking string No edit_distance, ngrams, or both

For suffix-resolved forms, the default edit-distance ranking reuses the materialized results of the resolved root. For example, मुखबाट uses the precomputed related words for मुख rather than calculating a new ranking at request time.

Example Request

curl "https://sabdasakha.com/api/v1/dictionary/related?q=घर&limit=5"

Success Response (200)

{
  "word": "घर",
  "related_words": ["घरघर", "घरबार", "गृह"]
}

Parts of Speech Reference

Code Meaning English
नाम नाम Noun
क्रि. क्रिया Verb
वि. विशेषण Adjective
क्रि.वि. क्रियाविशेषण Adverb
सर्व. सर्वनाम Pronoun
नि. निपात Particle
सं. संयोजक Conjunction
अ. अव्यय Indeclinable

Etymology is shown in brackets, e.g., [प्राकृत], [संस्कृत]


URL Encoding

Nepali text must be properly URL-encoded when passed as path or query parameters:

import urllib.parse

word = "नेपाल"
encoded = urllib.parse.quote(word)
url = f"https://sabdasakha.com/api/v1/dictionary/word/{encoded}"

Most HTTP libraries handle this automatically, but be aware when constructing URLs manually.


Best Practices

  1. Choose the lookup mode explicitly - Use default exact lookup, include_variants=true, or multi_dict=true depending on the response shape your client expects
  2. Cache responses - Word definitions don't change frequently
  3. Debounce autocomplete - Wait 200-300ms after user stops typing
  4. Handle 404s gracefully - Show similar word suggestions to users
  5. Use UTF-8 encoding - All requests and responses use UTF-8