ข้ามไปยังเนื้อหา

API Reference

หน้านี้แสดงรายการ API Endpoint ทั้งหมดสำหรับการเชื่อมต่อจากบุคคลที่สาม

การเชื่อมต่อจากบุคคลที่สามใช้ API Key ที่ส่งผ่านหัวข้อ x-api-key:

Terminal window
curl -H "x-api-key: dpk_YOUR_API_KEY" https://app.dailyplay.ai/api/...

Endpoint สำหรับจัดการจากแดชบอร์ดใช้ Clerk Bearer Token แทน:

Terminal window
curl -H "Authorization: Bearer <clerk_token>" https://app.dailyplay.ai/api/...

Endpoint เหล่านี้ใช้สำหรับการเชื่อมต่อจากบุคคลที่สามในการสร้างและจัดการเซสชันโทเค็นแบบใช้ครั้งเดียว

สร้างเซสชันโทเค็นแบบใช้ครั้งเดียวสำหรับเกมหรือสตรีม

POST /api/org-api-keys?action=create-session

Headers:

Headerค่า
Content-Typeapplication/json
x-api-keyAPI Key (dpk_...)

Body:

{
"game_id": 42,
"stream_id": null,
"external_ref": "user-12345",
"metadata": { "campaign": "summer-promo" },
"expires_in_minutes": 60
}
ฟิลด์ประเภทจำเป็นคำอธิบาย
game_idnumber*Game ID เป้าหมาย
stream_idnumber*Stream ID เป้าหมาย
external_refstringไม่อ้างอิงสำหรับติดตาม
metadataobjectไม่ข้อมูล JSON ตามต้องการ
expires_in_minutesnumberไม่ระยะเวลาหมดอายุ (ค่าเริ่มต้น: 1440)

* ต้องระบุ game_id หรือ stream_id อย่างน้อย 1 อย่าง

Response 200:

{
"success": true,
"data": {
"token": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"stream_id": null,
"game_id": 42,
"expires_at": "2026-02-17T12:00:00.000Z",
"external_ref": "user-12345"
}
}

ตรวจสอบว่าเซสชันโทเค็นยังใช้ได้หรือไม่โดยไม่ใช้โทเค็น

GET /api/org-api-keys?action=validate-session&token=<uuid>

Query Parameters:

พารามิเตอร์ประเภทจำเป็นคำอธิบาย
tokenstring (UUID)ใช่เซสชันโทเค็นที่ต้องการตรวจสอบ

Response 200:

{
"success": true,
"data": {
"valid": true,
"status": "active",
"stream_id": null,
"game_id": 42,
"expires_at": "2026-02-17T12:00:00.000Z",
"external_ref": "user-12345",
"metadata": { "campaign": "summer-promo" }
}
}

ใช้เซสชันโทเค็นแบบ atomic ทำให้ไม่สามารถใช้ซ้ำ

POST /api/org-api-keys?action=consume-session

Headers:

Headerค่า
Content-Typeapplication/json

Body:

{
"token": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"player_uuid": "player-uuid-here"
}
ฟิลด์ประเภทจำเป็นคำอธิบาย
tokenstring (UUID)ใช่เซสชันโทเค็นที่ต้องการใช้
player_uuidstringไม่UUID สำหรับระบุผู้เล่น

Response 200:

{
"success": true,
"data": {
"session_id": 1,
"org_id": 5,
"stream_id": null,
"game_id": 42,
"external_ref": "user-12345",
"metadata": { "campaign": "summer-promo" }
}
}

Response 410 (ใช้แล้ว/หมดอายุ):

{
"success": false,
"error": "Session is invalid, already consumed, or expired"
}

Endpoint เหล่านี้ต้องใช้ Clerk Bearer Token และใช้สำหรับจัดการ API Keys จากแดชบอร์ด DailyPlay

GET /api/org-api-keys?org_id=<id>

แสดง API Keys ทั้งหมดขององค์กรที่ระบุ


POST /api/org-api-keys

Body:

{
"org_id": 1,
"name": "Production CRM",
"description": "CRM ใช้สำหรับออกลิงก์เกม",
"allowed_game_ids": [42, 43],
"rate_limit_per_minute": 60,
"rate_limit_per_day": 10000,
"expires_at": "2027-01-01T00:00:00Z"
}