Rate Limits
The Sabdasakha API uses rate limiting to ensure fair usage and maintain service quality for all users.
Current Limits
| Tier | Requests/minute | Requests/day | API Key Required |
|---|---|---|---|
| Anonymous | 30 | 1,000 | No |
| Partner | 300 | 100,000 | Yes |
Rate Limit Headers
Every API response includes headers showing your current rate limit status:
| Header | Description |
|---|---|
X-RateLimit-Limit |
Maximum requests allowed per minute |
X-RateLimit-Remaining |
Requests remaining in current window |
X-RateLimit-Reset |
Unix timestamp when the limit resets |
Rate Limit Exceeded
When you exceed the rate limit, you'll receive a 429 Too Many Requests response:
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded. Please wait before making more requests.",
"retry_after": 60
}
}
Best Practices
1. Implement Exponential Backoff
When you receive a 429 response, wait before retrying:
import time
import requests
def make_request_with_retry(url, max_retries=3):
for attempt in range(max_retries):
response = requests.get(url)
if response.status_code == 429:
wait_time = 2 ** attempt # 1, 2, 4 seconds
time.sleep(wait_time)
continue
return response
raise Exception("Max retries exceeded")
2. Cache Responses
Dictionary definitions don't change frequently. Cache responses locally:
from functools import lru_cache
@lru_cache(maxsize=1000)
def lookup_word(word):
response = requests.get(f"https://sabdasakha.com/api/v1/dictionary/word/{word}")
return response.json()
3. Batch Spellcheck Requests
Instead of checking words one at a time, use the batch endpoint:
# Instead of this (4 requests):
for word in ["नेपाल", "भारत", "चीन", "जापान"]:
check_word(word)
# Do this (1 request):
response = requests.post(
"https://sabdasakha.com/api/v1/spellcheck/text",
json={"text": "नेपाल भारत चीन जापान"}
)
4. Debounce Autocomplete
For search-as-you-type, debounce requests to avoid hitting limits:
let timeoutId;
function onSearchInput(query) {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
fetch(`https://sabdasakha.com/api/v1/dictionary/suggest?q=${query}`);
}, 300); // Wait 300ms after user stops typing
}
Partner Access
Need higher rate limits for your application? Contact us on Twitter (@sabdasakha) with:
- Your application name and description
- Expected request volume
- Your use case
Partner access is free for educational and non-commercial projects.