API Documentation

เอกสารสำหรับนักพัฒนาที่ต้องการใช้งาน API ของระบบ

Overview

This API provides access to the Digital Collections database. All endpoints return data in JSON format.

The API is read-only and does not require authentication.

Endpoints

Get All Items

GET /api/items

Returns a list of all items in the collection.

Example Response:

[
  {
    "id": "CMRU-CT-01-A-0001",
    "title": "ปารมี",
    "alt.title": "",
    "type": "คัมภีร์ใบลาน",
    "subject": "ธรรมทั่วไป",
    "language": "ไทขืน",
    "script": "ไทขึน",
    "author": "วัดอินทบุปผาราม เมืองเชียงตุง",
    "year": "2532",
    "description": null,
    "spatial": "วัดอินทบุปผาราม เมืองเชียงตุง",
    "country": "เมียนมาร์",
    "province": "เชียงตุง",
    "source.uri": "https://example.com/items/12",
    "image": "https://example.com/storage/images/000-DSCF8430(1).jpg"
  },
  ...
]

Get Item by ID

GET /api/items/{id}

Returns detailed information about a specific item.

Parameters:

  • id - The item ID

Example Response:

{
  "id": "CMRU-CT-01-A-0001",
  "title": "ปารมี",
  "alt.title": "",
  "type": "คัมภีร์ใบลาน",
  "subject": "ธรรมทั่วไป",
  "language": "ไทขืน",
  "script": "ไทขึน",
  "author": "วัดอินทบุปผาราม เมืองเชียงตุง",
  "year": "2532",
  "description": "คัมภีร์ใบลานโบราณจากวัดอินทบุปผาราม",
  "spatial": "วัดอินทบุปผาราม เมืองเชียงตุง",
  "country": "เมียนมาร์",
  "province": "เชียงตุง",
  "source.uri": "https://example.com/items/12",
  "image": "https://example.com/storage/images/000-DSCF8430(1).jpg",
  "images": [
    "https://example.com/storage/images/000-DSCF8430(1).jpg",
    "https://example.com/storage/images/000-DSCF8431.jpg"
  ],
  "files": [
    {
      "name": "ปารมี.pdf",
      "path": "https://example.com/storage/files/ปารมี.pdf",
      "type": "pdf",
      "size": 1024000,
      "is_main": true
    }
  ],
  "created_at": "2023-01-01T00:00:00.000000Z",
  "updated_at": "2023-01-01T00:00:00.000000Z"
}

Legacy API Endpoint

GET /manuscript-api.php

This endpoint is provided for backward compatibility. It returns the same data as the /api/items endpoint.

Example Usage

JavaScript Example

fetch('/api/items')
  .then(response => response.json())
  .then(data => {
    console.log(data);
    // Process the data
  })
  .catch(error => console.error('Error:', error));

PHP Example

$url = 'https://example.com/api/items';
$response = file_get_contents($url);
$data = json_decode($response, true);

// Process the data
print_r($data);