Welcome to the English-Khmer Dictionary API documentation. This RESTful API provides access to dictionary data with authentication, rate limiting, and subscription management.
Authorization: Bearer YOUR_TOKEN
Register a new user account.
| Parameter | Type | Description |
|---|---|---|
| email Required | string | User email address |
| password Required | string | User password |
| name Required | string | User's full name |
{
"error": "User already exists"
}
{
"message": "User created successfully",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"email": "user@example.com",
"name": "John Doe"
}
}
Authenticate and receive a JWT token.
| Parameter | Type | Description |
|---|---|---|
| email Required | string | User email address |
| password Required | string | User password |
{
"message": "Login successful",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImV4cCI6MTcxNDc2ODAwMH0.abc123...",
"user": {
"id": 1,
"email": "user@example.com",
"name": "John Doe"
}
}
{
"error": "Invalid credentials"
}
Get current authenticated user information.
{
"user": {
"id": 1,
"email": "user@example.com",
"name": "John Doe"
}
}
{
"error": "Invalid or expired token"
}
Search for words in the dictionary. Supports partial matching and pagination.
Note: You can also use /api/dictionary without the /search path.
| Parameter | Type | Default | Description |
|---|---|---|---|
| query Optional | string | - | Search query (partial match, case-insensitive). If omitted, returns all words with pagination. |
| limit Optional | integer | 100 | Maximum number of results to return (1-1000) |
| offset Optional | integer | 0 | Number of results to skip for pagination |
Alternative: GET /api/dictionary?query=hello&limit=10
Alternative: GET /api/dictionary?limit=50&offset=0
Alternative: GET /api/dictionary?query=book&limit=20&offset=20
{
"words": [
{
"id": 123,
"englishWord": "hello",
"partOfSpeech": "noun",
"englishPhonetic": "hΙΛloΚ",
"khmerPhonetic": "αα½ααααΈ",
"khmerDef": "<ul><li><span style=\"color: #0000ff\">greeting</span></li></ul>"
},
{
"id": 124,
"englishWord": "hello there",
"partOfSpeech": "phrase",
"englishPhonetic": "hΙΛloΚ Γ°Ιr",
"khmerPhonetic": "αα½ααααΈαα
ααΈααα",
"khmerDef": "<ul><li>A friendly greeting</li></ul>"
}
],
"count": 2
}
| Field | Type | Description |
|---|---|---|
| words | array | Array of word objects matching the search |
| words[].id | integer | Unique word identifier |
| words[].englishWord | string | The English word |
| words[].partOfSpeech | string | Part of speech (noun, verb, adjective, etc.) |
| words[].englishPhonetic | string | English phonetic pronunciation |
| words[].khmerPhonetic | string | Khmer phonetic pronunciation |
| words[].khmerDef | string | Khmer definition (HTML formatted) |
| count | integer | Number of words returned in this response |
Get a specific word by ID or exact match. Returns a single word object.
| Parameter | Type | Description |
|---|---|---|
| id Optional | integer | Word ID (e.g., 123). Either id or word must be provided. |
| word Optional | string | Exact word match (case-insensitive, e.g., "hello") |
Note: You must provide either id or word parameter.
Alternative: GET /api/dictionary?id=123
Alternative: GET /api/dictionary?word=hello
{
"id": 123,
"englishWord": "hello",
"partOfSpeech": "noun",
"englishPhonetic": "hΙΛloΚ",
"khmerPhonetic": "αα½ααααΈ",
"khmerDef": "<ul><li><span style=\"color: #0000ff\">greeting</span></li></ul>"
}
{
"error": "Word not found"
}
Get all available subscription plans with their rate limits and pricing.
Note: This endpoint does not require authentication.
{
"plans": [
{
"id": "free",
"name": "Free",
"rateLimit": 10,
"price": 0
},
{
"id": "basic",
"name": "Basic",
"rateLimit": 50,
"price": 9.99
},
{
"id": "premium",
"name": "Premium",
"rateLimit": 200,
"price": 19.99
},
{
"id": "enterprise",
"name": "Enterprise",
"rateLimit": 1000,
"price": 49.99
}
]
}
Get the current user's active subscription and rate limit information.
{
"subscription": {
"id": 5,
"user_id": 1,
"plan_name": "Premium",
"rate_limit": 200,
"status": "active",
"created_at": "2024-01-01 00:00:00",
"expires_at": "2024-02-01 00:00:00"
},
"currentRateLimit": 200,
"plan": "premium"
}
{
"subscription": null,
"currentRateLimit": 10,
"plan": "free"
}
Get current rate limit status including remaining requests and reset time.
{
"rateLimit": 200,
"currentCount": 45,
"resetAt": "2024-01-01T00:01:00+00:00",
"remaining": 155
}
Subscribe to a plan.
| Parameter | Type | Description |
|---|---|---|
| planId Required | string | Plan ID: free, basic, premium, or enterprise |
{
"message": "Subscription successful",
"subscription": {
"id": 5,
"planName": "Premium",
"rateLimit": 200,
"expiresAt": "2024-02-01T00:00:00+00:00"
}
}
{
"error": "Invalid plan ID"
}
Check API health status.
{
"status": "ok",
"dictionary": "connected",
"timestamp": "2024-01-01T00:00:00+00:00"
}
{
"error": "Authentication required"
}
{
"error": "Rate limit exceeded",
"message": "You have exceeded your rate limit...",
"rateLimit": 10,
"resetAt": "2024-01-01T00:01:00+00:00"
}
{
"error": "Internal server error"
}