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
or
| 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
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:
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:
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.
Autocomplete Suggestions
Get word suggestions for search-as-you-type functionality.
Request
| 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
Success Response (200)
The response is a simple array of matching words:
[
"नेपाल",
"नेपाल औद्योगिक विकास कर्पोरेसन",
"नेपाल तारा",
"नेपाल प्रज्ञा प्रतिष्ठान",
"नेपाल प्रताप भास्कर"
]
Empty Results
If no matches are found:
Related Words
Get orthographically related public dictionary headwords for an existing word.
Request
| 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
Success Response (200)
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
- Choose the lookup mode explicitly - Use default exact lookup,
include_variants=true, ormulti_dict=truedepending on the response shape your client expects - Cache responses - Word definitions don't change frequently
- Debounce autocomplete - Wait 200-300ms after user stops typing
- Handle 404s gracefully - Show similar word suggestions to users
- Use UTF-8 encoding - All requests and responses use UTF-8