A modern, high-performance REST API for the Kamus Besar Bahasa Indonesia (KBBI), built with Node.js, Express 5, and TypeScript. This API scrapes the official KBBI site to provide structured, machine-readable definitions.
- Modern Stack: Built with Express 5, Axios, and Cheerio.
- TypeScript: Fully typed for better developer experience and reliability.
- Clean Architecture: Follows the Controller-Service pattern for maintainability.
- Structured Data: Provides definitions, word classes (e.g., noun, verb), and headwords in a clean JSON format.
- Reliable Scraper: Updated for the latest KBBI website structure with robust error handling.
-
Clone the repository:
git clone https://github.com/your-username/kbbi-api.git cd kbbi-api -
Install dependencies:
npm install
-
Set up Environment Variables: Create a
.envfile in the root directory:PORT=3000 BASE_URL=http://localhost:3000
-
Build the project:
npm run build
-
Start the server:
# Development mode (with auto-reload) npm run dev # Production mode npm start
http://localhost:3000
Returns basic information about the API.
- URL:
/ - Method:
GET - Success Response:
- Code: 200 OK
- Content:
{ "message": "Welcome to New KBBI API", "endpoint": "/search/[word]", "example": "http://localhost:3000/search/demokrasi" }
Searches for a specific word in the KBBI database.
- URL:
/search/:word - Method:
GET - URL Params:
word(Required): The word to search for.
- Success Response:
- Code: 200 OK
- Content:
{ "success": true, "message": "Search successful", "data": [ { "headword": "de.mo.kra.si /démokrasi/", "definitions": [ { "wordClass": "n[Nomina: kata benda] Pol[Politik dan Pemerintahan: -]", "description": "(bentuk atau sistem) pemerintahan yang seluruh rakyatnya turut serta memerintah dengan perantaraan wakilnya; pemerintahan rakyat" }, { "wordClass": "n[Nomina: kata benda] Pol[Politik dan Pemerintahan: -]", "description": "gagasan atau pandangan hidup yang mengutamakan persamaan hak and kewajiban serta perlakuan yang sama bagi semua warga negara" } ] } ] }
- Error Responses:
- 404 Not Found:
{ "success": false, "message": "Word not found" } - 500 Internal Server Error:
{ "success": false, "message": "Internal server error", "error": "Error message details" }
- 404 Not Found:
src/
├── config/ # Configuration and environment variables
├── controllers/ # Request handling and response logic
├── interfaces/ # TypeScript interfaces and types
├── routes/ # API route definitions
├── services/ # Business logic and scraping logic
├── app.ts # Express application setup
└── server.ts # Server entry point
This project is licensed under the ISC License.
Built with ❤️