Spellcheck API
The Spellcheck API validates Nepali text and provides correction suggestions for misspelled words.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/spellcheck/text |
Check spelling of text |
| GET | /api/v1/spellcheck/word |
Check a single word |
Check Text
Validate a block of Nepali text and get suggestions for misspelled words.
Request
| Field | Type | Required | Description |
|---|---|---|---|
text |
string | Yes | The Nepali text to check |
Example Request
const response = await fetch(
"https://sabdasakha.com/api/v1/spellcheck/text",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
text: "नेपाल सुन्दर देस हो"
})
}
);
const result = await response.json();
result.misspelled.forEach(error => {
console.log(`${error.word} -> ${error.corrections.join(", ")}`);
});
Success Response (200)
{
"misspelled": [
{
"word": "देस",
"status": "misspelled",
"corrections": ["देश"]
}
],
"unknown": []
}
| Field | Type | Description |
|---|---|---|
misspelled |
array | List of misspelled words with corrections |
misspelled[].word |
string | The misspelled word |
misspelled[].status |
string | Always "misspelled" |
misspelled[].corrections |
array | Correction suggestions |
unknown |
array | Words not found in dictionary (no corrections available) |
No Errors Response
When all words are spelled correctly:
Check Single Word
Check the spelling of a single word.
Request
| Parameter | Type | Required | Description |
|---|---|---|---|
word |
string | Yes | The word to check |
Example Request
Response - Misspelled Word
Response - Correct Word
Response - Unknown Word
| Field | Type | Description |
|---|---|---|
status |
string | One of: "correct", "misspelled", "unknown" |
corrections |
array|null | Correction suggestions (null if correct or unknown) |
How It Works
The spellcheck API uses a multi-stage validation process:
- Bloom Filter - Fast probabilistic check (0.1% false positive rate)
- Root Word Analysis - Checks word stems and common suffixes
- Dictionary Lookup - Validates against comprehensive word vocabulary
- Fuzzy Matching - Generates suggestions using edit distance
This approach provides sub-100ms response times for typical text.
Text Limits
The API enforces the following limits and returns 400 Bad Request when exceeded:
| Limit | Value |
|---|---|
| Maximum text length | 10,000 characters |
| Maximum words per request | 1,000 words |
For larger documents, split the text into chunks.
Limit Exceeded Response (400)
Common Misspellings
The API is trained to catch common Nepali spelling errors:
| Error Type | Example | Correct |
|---|---|---|
| ष/स confusion | देस | देश |
| ृ/्र confusion | प्रक्रति | प्रकृति |
| Half-letter errors | गर्नु | गर्नु |
| Chandrabindu | हुछ | हुँछ |
Best Practices
- Batch requests - Check full paragraphs instead of word-by-word
- Cache common words - Reduce API calls for frequently typed words
- Limit suggestions shown - Display 2-3 suggestions, not all
- Handle unknown words - These may be proper nouns or technical terms