API Documentation

Access LaoCorpus data programmatically through our REST API. Perfect for researchers, developers, and AI practitioners.

Quick Start

1. Request API access through our Access Request Form

2. Receive your API key via email after approval

3. Include your API key in the Authorization header: Authorization: Bearer YOUR_API_KEY

4. Start making requests to our endpoints

API Endpoints

/api/upload
Upload a document (PDF/DOCX/TXT/Audio/Video) to LaoCorpus
POST

Request Body:

{
  "file": "multipart/form-data",
  "title": "string (required)",
  "author": "string (optional)",
  "category": "enum (required)",
  "year": "integer (optional)"
}

Response Example:

{
  "success": true,
  "documentId": 157,
  "title": "ປະຫວັດສາດລາວ",
  "tokenCount": 15234,
  "message": "Document uploaded successfully"
}
/api/getMetadata
Get metadata of all documents or specific document
GET

Parameters:

id(integer)Document ID (optional)

Response Example:

{
  "documents": [
    {
      "id": 1,
      "title": "ປະຫວັດສາດລາວ",
      "author": "ດຣ.ໄພວັນ ມາລາວົງ",
      "category": "Education",
      "year": 2023,
      "tokenCount": 15234,
      "source": "National Library"
    }
  ],
  "total": 156
}
/api/getCorpus
Get full corpus data with text content
GET

Parameters:

category(string)Filter by category (optional)
limit(integer)Max results (default: 100)
offset(integer)Skip results (default: 0)

Response Example:

{
  "documents": [
    {
      "id": 1,
      "title": "ປະຫວັດສາດລາວ",
      "textContent": "ປະເທດລາວມີປະຫວັດສາດອັນຍາວນານ...",
      "tokenCount": 15234,
      "metadata": {
        "author": "ດຣ.ໄພວັນ ມາລາວົງ",
        "year": 2023
      }
    }
  ],
  "total": 156,
  "hasMore": true
}
/api/tokenCount
Get token count statistics
GET

Parameters:

category(string)Filter by category (optional)

Response Example:

{
  "totalTokens": 1234567,
  "totalDocuments": 156,
  "byCategory": [
    { "category": "Education", "count": 45, "tokens": 456789 },
    { "category": "Literature", "count": 32, "tokens": 345678 }
  ],
  "lastUpdated": "2025-12-07T10:30:00Z"
}

Code Examples

# Upload document
curl -X POST "https://sambai.ai/api/upload" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "[email protected]" \
  -F "title=ປະຫວັດສາດລາວ" \
  -F "category=Education"

# Get metadata
curl -X GET "https://sambai.ai/api/getMetadata?id=1" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Get corpus data
curl -X GET "https://sambai.ai/api/getCorpus?category=Education&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Get token counts
curl -X GET "https://sambai.ai/api/tokenCount" \
  -H "Authorization: Bearer YOUR_API_KEY"
Rate Limits

Free Tier: 100 requests/day

Academic Tier: 1,000 requests/day

Commercial Tier: 10,000 requests/day

Need higher limits? View our pricing plans