กลับหน้าหลัก
Developer API

Client API Documentation

คู่มือการเชื่อมต่อระบบกับ Allwell Smart Care ผ่าน Client API สำหรับนักพัฒนา

Authentication & Security

การเรียกใช้ API ทุกครั้ง (ยกเว้นการขอ Token) จะต้องแนบ Access Token ใน Header Authorization: Bearer <your_token> เอกสารนี้จะอธิบายวิธีการขอ Token และการดึงข้อมูลต่างๆ

Base URL:ติดต่อเจ้าหน้าที่

Create Access Token

POST/token

ใช้สำหรับขอ Access Token เพื่อใช้ในการเรียก API อื่นๆ โดยใช้ Client ID และ Client Secret

Request Body
{
  "client_id": "clt_mock_123456",
  "client_secret": "sk_mock_888888888888888888888888888888888888888888888"
}
Response Sample
{
  "success": true,
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "expiresIn": 3600
  }
}

Get Client Info

GET/info
Bearer Token

ดึงข้อมูลรายละเอียดของ Client ที่กำลังใช้งานอยู่

Response Sample
{
  "success": true,
  "data": {
    "id": 1,
    "name": "Hospital Partner A",
    "client_id": "clt_mock_123456",
    "is_active": true,
    "created_at": "2024-01-01T00:00:00.000Z",
    "Hospitals": [
      {
        "id": 101,
        "name": "Allwell General Hospital"
      },
      {
        "id": 102,
        "name": "Allwell Wellness Center"
      }
    ]
  }
}

Get Patients

GET/patients
Bearer Token

รายชื่อผู้ป่วยทั้งหมดที่อยู่ภายใต้การดูแลของ Client นี้ สามารถใส่ query parameter page และ limit ได้

Response Sample
{
  "success": true,
  "meta": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "totalPages": 8
  },
  "data": [
    {
      "id": 1,
      "hn": "HN-2025-0001",
      "hospitalId": 101,
      "firstName": "Somsak",
      "lastName": "Jai-dee",
      "phoneNumber": "081-222-3333",
      "email": "somsak@example.com",
      "diabetesType": "Type 2",
      "target": {
        "preMeal": { "high": 130, "low": 80 },
        "postMeal": { "high": 180, "low": 90 }
      },
      "createdAt": "2024-12-01T08:00:00Z",
      "hospital": {
        "id": 101,
        "name": "Allwell General Hospital"
      }
    }
  ]
}

Get Patient Histories

GET/patients/:id/histories
Bearer Token

ดึงประวัติข้อมูลสุขภาพของผู้ป่วยรายบุคคล (Blood Sugar) สามารถใส่ query parameter page และ limit ได้

Response Sample
{
  "success": true,
  "meta": {
    "page": 1,
    "limit": 10,
    "total": 45,
    "totalPages": 5
  },
  "data": [
    {
      "glucose": 115,
      "measureType": "AC",
      "measuredAt": "2025-01-20T07:30:00Z",
      "createdAt": "2025-01-20T07:35:00Z"
    },
    {
      "glucose": 145,
      "measureType": "PC",
      "measuredAt": "2025-01-19T13:00:00Z",
      "createdAt": "2025-01-19T13:10:00Z"
    }
  ]
}

ต้องการ API Key เพิ่มเติม?

หากคุณต้องการเชื่อมต่อระบบหรือพบปัญหาในการใช้งาน สามารถติดต่อทีม Engineer ของเราเพื่อขอความช่วยเหลือได้ทันที