สร้างบน s.id — REST API, Webhooks & OAuth
สร้างลิงก์สั้น ติดตามคลิก และทำให้กระบวนการทำงานของคุณอัตโนมัติด้วยแพลตฟอร์มนักพัฒนา s.id รับรองความถูกต้องด้วย API key ง่ายๆ webhook แบบเรียลไทม์ และ OAuth 2.0 สำหรับแอปของบุคคลที่สาม
REST API
จัดการลิงก์ QR code และข้อมูลผู้ใช้ด้วย JSON API ที่สะอาด Bearer token auth 38 req/นาที
เรียนรู้เพิ่มเติมWebhooks
สมัครรับ link.created, link.clicked, qr.scanned และอื่นๆ เพย์โหลดที่เซ็นชื่อด้วย HMAC
เรียนรู้เพิ่มเติมOAuth 2.0
Authorization-code flow พร้อม PKCE และการหมุนเวียน refresh token ให้แอปของคุณทำงานในนามของผู้ใช้ s.id
เรียนรู้เพิ่มเติมเริ่มต้นอย่างรวดเร็ว
สร้างลิงก์สั้นในการเรียก API เพียงครั้งเดียว
เปิด Dashboard → Developer → API Keys
สร้าง key ที่มีสิทธิ์ที่คุณต้องการ
เรียก API ด้วย Bearer sk_live_...
URL พื้นฐาน: https://api.s.id/v2
curl -X POST https://api.s.id/v2/links \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"long_url": "https://example.com/long-url", "custom_slug": "mylink"}'Endpoints
ทุก endpoint ต้องใช้ API key ที่มีสิทธิ์ที่เหมาะสม
| วิธีการ | พาธ |
|---|---|
| GET | /links |
| POST | /links |
| POST | /links/available |
| GET | /links/{short} |
| PUT | /links/{short} |
| DELETE | /links/{short} |
| POST | /links/{short}/unarchive |
| GET | /links/{short}/stats |
| GET | /links/{short}/stats/lifetime |
| GET | /user |
| GET | /quota |
| GET | /microsites |
| POST | /microsites |
| GET | /microsites/{slug} |
| PUT | /microsites/{slug} |
| DELETE | /microsites/{slug} |
| POST | /links/bulk |
| GET | /stats |
| GET | /qr |
| PUT | /qr |
| GET | /links/{short}/qr |
| PUT | /links/{short}/qr |
| POST | /microsites/available |
| GET | /microsites/{slug}/components |
| POST | /microsites/{slug}/components |
| PUT | /microsites/{slug}/components/{componentId} |
| DELETE | /microsites/{slug}/components/{componentId} |
| POST | /microsites/{slug}/components/order |
| GET | /oauth/authorize |
| POST | /oauth/token |
| POST | /oauth/revoke |
| GET | /oauth/userinfo |
| GET | /api/user/oauth/apps |
| DELETE | /api/user/oauth/apps/{clientId} |
API Scopes
API key แต่ละตัวมีสิทธิ์กำหนด — ขอเฉพาะสิทธิ์ที่การเชื่อมต่อของคุณต้องการ
links:readList and read linkslinks:writeCreate and update links (create, edit, restore)links:archiveArchive linkslinks:analyticsRead per-link click statistics and lifetime countsqr:readRead QR code settings (global and per-link)qr:writeCustomize QR code settings (global and per-link)user:readRead the authenticated user profile and account quotamicrosites:readRead micrositesmicrosites:writeCreate, update, delete and manage components of micrositesWebhooks
ลงทะเบียน endpoint HTTPS เพื่อรับเหตุการณ์แบบเรียลไทม์ การส่งแต่ละครั้งจะลงนาม POST ด้วย HMAC-SHA256
เหตุการณ์ที่มีให้
link.createdFired when a new link is createdlink.updatedFired when a link's URL or title is changedlink.archivedFired when a link is archivedlink.clickedFired on each redirect (per-click event)microsite.publishedFired when a microsite is publishedqr.scannedFired when a QR code is scannedตัวอย่าง payload
{
"event": "link.created",
"link": {
"id": 123,
"short": "mylink",
"short_url": "https://s.id/mylink",
"long_url": "https://example.com/long-url",
"title": "My Link",
"created": "2026-06-22T10:00:00Z"
},
"timestamp": "2026-06-22T10:00:00Z"
}ตรวจสอบลายเซ็น (Node.js)
const crypto = require('crypto');
function verifySignature(secret, rawBody, sigHeader) {
const expected = 'sha256=' +
crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
return crypto.timingSafeEqual(
Buffer.from(sigHeader),
Buffer.from(expected),
);
}Secret จะแสดงครั้งเดียวเมื่อคุณสร้าง webhook ตรวจสอบก่อนประมวลผลเหตุการณ์
การรับรองความถูกต้อง
สองวิธีในการรับรองความถูกต้อง: API key สำหรับ server-to-server, OAuth 2.0 สำหรับการทำงานแทนผู้ใช้
API Keys
สร้าง key ใน Dashboard → Developer → API Keys ส่งเป็น Bearer token Key มีสิทธิ์กำหนดและสามารถยกเลิกได้ตลอดเวลา
Authorization: Bearer sk_live_...OAuth 2.0
ใช้ authorization-code flow เพื่อทำงานแทนผู้ใช้ s.id เปลี่ยนเส้นทางไปยัง /oauth/authorize แลกเปลี่ยน code ที่ /oauth/token
คู่มือ OAuth 2.0พร้อมเริ่มสร้างแล้วหรือยัง?
สร้าง API key ในไม่กี่นาที มีแพ็กเกจฟรี — ไม่ต้องใช้บัตรเครดิต