Backend API for the KBBI Assistant mobile app, deployed on Cloudflare Workers.
- Word Lookup: Check if a word exists in KBBI
- Word Details: Get complete word information (meanings, word class, etymology, etc.)
- Non-Standard Check: Check if a word is in standard form and get suggestions
- Similar Words: Get typo suggestions using Levenshtein distance
- Search: Search words by prefix or substring
- High Performance: Deployed on Cloudflare's global edge network with KV storage
- CORS Enabled: Ready for mobile and web apps
GET /api/lookup/:word
Example:
curl https://your-worker.workers.dev/api/lookup/rumahResponse:
{
"exists": true,
"word": "rumah"
}GET /api/word/:word
Example:
curl https://your-worker.workers.dev/api/word/rumahResponse:
{
"status": "success",
"data": {
"pranala": "https://kbbi.kemdikbud.go.id/entri/rumah",
"entri": [
{
"nama": "rumah",
"kata_dasar": ["rumah"],
"makna": [...],
"etimologi": "...",
...
}
]
}
}GET /api/check/:word
Example:
curl https://your-worker.workers.dev/api/check/rumahResponse:
{
"is_standard": true,
"word": "rumah",
"non_standard_forms": ["ruma"]
}GET /api/similar/:word?limit=5
Example:
curl https://your-worker.workers.dev/api/similar/rumh?limit=5Response:
{
"word": "rumh",
"suggestions": [
{ "word": "rumah", "distance": 1 },
{ "word": "ruma", "distance": 1 }
]
}GET /api/search?q=query&limit=10
Example:
curl https://your-worker.workers.dev/api/search?q=rum&limit=10Response:
{
"query": "rum",
"count": 10,
"results": ["rumah", "rumania", "rumbia", ...]
}GET /api/stats
Response:
{
"total_words": 112651,
"api_version": "1.0.0",
"endpoints": [...]
}- Cloudflare Account: Sign up at cloudflare.com
- Wrangler CLI: Already installed in this project
- Node.js: Version 18 or higher
Process the KBBI JSON files and create KV-ready data:
npm run prepare-dataThis will create:
kv-data/directory with processed data- Word index files
- Non-standard word mappings
- Bulk upload JSON files
npx wrangler kv:namespace create KBBI_DATAYou'll get output like:
{ binding = "KBBI_DATA", id = "xxxxxxxxxxxxx" }
For preview (development):
npx wrangler kv:namespace create KBBI_DATA --previewEdit wrangler.toml and replace the KV namespace IDs:
[[kv_namespaces]]
binding = "KBBI_DATA"
id = "your_production_namespace_id"
preview_id = "your_preview_namespace_id"Upload the processed data to Cloudflare KV:
cd kv-data
# Set your namespace ID
export KV_NAMESPACE_ID="your_namespace_id"
# Upload using the generated script
./upload-to-kv.shOr upload manually using the bulk upload files:
npx wrangler kv:bulk put kv-data/bulk_upload_1.json --namespace-id=your_namespace_id
npx wrangler kv:bulk put kv-data/bulk_upload_2.json --namespace-id=your_namespace_id
# ... continue for all bulk filesnpm run devVisit http://localhost:8787 to test the API locally.
npm run deployYour API will be deployed to https://kbbi-api.your-subdomain.workers.dev
const KBBI_API_URL = 'https://your-worker.workers.dev';
// Check if word exists
async function checkWord(word) {
const response = await fetch(`${KBBI_API_URL}/api/lookup/${word}`);
return response.json();
}
// Get word details
async function getWordDetails(word) {
const response = await fetch(`${KBBI_API_URL}/api/word/${word}`);
return response.json();
}
// Get typo suggestions
async function getSuggestions(word) {
const response = await fetch(`${KBBI_API_URL}/api/similar/${word}?limit=5`);
return response.json();
}
// Search words
async function searchWords(query) {
const response = await fetch(`${KBBI_API_URL}/api/search?q=${query}&limit=10`);
return response.json();
}- KV Storage: All words are cached in Cloudflare KV (low-latency key-value store)
- Edge Network: Deployed globally for minimal latency
- HTTP Caching: Response caching with appropriate
Cache-Controlheaders - CORS: Pre-configured for cross-origin requests
View logs and analytics:
npx wrangler tailOr visit the Cloudflare Dashboard for detailed analytics.
Cloudflare Workers Free Tier includes:
- 100,000 requests/day
- Unlimited KV reads
- 1,000 KV writes/day
- 1 GB KV storage
This should be sufficient for development and moderate production use.
KBBI dataset from: kbbi-dataset-kbbi-v-main
Copyright: All data is owned by Badan Pengembangan dan Pembinaan Bahasa, Kementerian Pendidikan, Kebudayaan, Riset, dan Teknologi Republik Indonesia.
License: Non-commercial use only. See dataset README for details.
If bulk upload fails due to size limits, split the data into smaller chunks or use individual key uploads.
- Ensure you're logged in:
npx wrangler login - Check your Cloudflare account has Workers enabled
- Verify wrangler.toml configuration
- Verify KV namespace is correctly bound in wrangler.toml
- Check data was uploaded successfully:
npx wrangler kv:key list --namespace-id=your_id
After deployment:
- Test all endpoints with real data
- Integrate with React Native app
- Add rate limiting if needed
- Set up custom domain (optional)
- Monitor usage and performance
For issues or questions, please refer to: