s.id Logo
s.id
แพลตฟอร์มนักพัฒนา

สร้างบน 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 เพียงครั้งเดียว

1

เปิด Dashboard → Developer → API Keys

2

สร้าง key ที่มีสิทธิ์ที่คุณต้องการ

3

เรียก 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 Reference ฉบับเต็ม ↗

API Scopes

API key แต่ละตัวมีสิทธิ์กำหนด — ขอเฉพาะสิทธิ์ที่การเชื่อมต่อของคุณต้องการ

links:readList and read links
links:writeCreate and update links (create, edit, restore)
links:archiveArchive links
links:analyticsRead per-link click statistics and lifetime counts
qr: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 quota
microsites:readRead microsites
microsites:writeCreate, update, delete and manage components of microsites

Webhooks

ลงทะเบียน endpoint HTTPS เพื่อรับเหตุการณ์แบบเรียลไทม์ การส่งแต่ละครั้งจะลงนาม POST ด้วย HMAC-SHA256

เหตุการณ์ที่มีให้

link.createdFired when a new link is created
link.updatedFired when a link's URL or title is changed
link.archivedFired when a link is archived
link.clickedFired on each redirect (per-click event)
microsite.publishedFired when a microsite is published
qr.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 ตรวจสอบก่อนประมวลผลเหตุการณ์

คู่มือ webhooks ฉบับเต็ม

การรับรองความถูกต้อง

สองวิธีในการรับรองความถูกต้อง: 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 ในไม่กี่นาที มีแพ็กเกจฟรี — ไม่ต้องใช้บัตรเครดิต