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

Glossary

EnglishThai Styleความหมาย
RESTRESTRepresentational State Transfer — แนวทางออกแบบ API ผ่าน HTTP ที่เน้น resource
Resourceresourceสิ่งที่ API เปิดเผย เช่น user, order, product — มี URI เป็นของตัวเอง
EndpointendpointURL + method รวมกัน เช่น GET /users
URIURIUniform Resource Identifier — ที่อยู่ของ resource
URLURLURI ที่ระบุ location ได้จริง เช่น https://api.example.com/users
Contractcontractข้อตกลงระหว่าง API producer และ consumer — กำหนด request/response format
HATEOASHATEOASHypermedia As The Engine Of Application State — response มี link บอก action ต่อไป
Idempotencyidempotencyทำซ้ำกี่ครั้งก็ได้ผลลัพธ์เดิม — GET, PUT, DELETE เป็น idempotent
EnglishThai Styleความหมาย
Requestrequestข้อความจาก client ไปยัง server
Responseresponseข้อความตอบกลับจาก server
Headerheadermetadata ของ request/response เช่น Content-Type, Authorization
Bodybodyเนื้อหาหลักของ request/response
Payloadpayloadข้อมูลที่ส่งใน body
Status Codestatus codeตัวเลข 3 หลักที่บอกผลลัพธ์ เช่น 200, 404, 500
MethodmethodGET, POST, PUT, PATCH, DELETE, OPTIONS
GETGETอ่านข้อมูล — idempotent, cacheable
POSTPOSTสร้าง resource ใหม่ — ไม่ idempotent
PUTPUTแทนที่ resource ทั้งหมด — idempotent
PATCHPATCHแก้ไขบางส่วน — อาจ idempotent
DELETEDELETEลบ resource — idempotent
CodeMeaningเมื่อใช้
200 OKสำเร็จGET, PATCH, PUT สำเร็จ
201 Createdสร้างสำเร็จPOST ที่สร้าง resource ใหม่
204 No Contentสำเร็จ ไม่มี bodyDELETE สำเร็จ
400 Bad Requestrequest ผิดvalidation error, format ผิด
401 Unauthorizedยังไม่ได้ authenticateไม่มี token หรือ token หมดอายุ
403 Forbiddenไม่มีสิทธิ์authenticate แล้วแต่ไม่มีสิทธิ์
404 Not Foundไม่พบ resourceresource ไม่มีอยู่
409 Conflictเกิด conflictduplicate, state ไม่ถูกต้อง
422 Unprocessableข้อมูลผิด semanticfield ถูก format แต่ logic ผิด
429 Too Many Requestsถูก rate limitเกิน quota
500 Internal Server Errorserver errorbug ฝั่ง server
EnglishThai Styleความหมาย
Authenticationauthenticationพิสูจน์ว่า “คุณคือใคร”
Authorizationauthorizationตรวจสอบว่า “คุณทำอะไรได้บ้าง”
JWTJWTJSON Web Token — token ที่เข้ารหัสข้อมูล user
Bearer TokenBearer Tokentoken ใน header Authorization: Bearer <token>
OAuthOAuthprotocol มาตรฐานสำหรับ delegated authorization
API KeyAPI Keykey ที่ใช้ระบุ client — ง่ายแต่ไม่ revocable ได้ดี
EnglishThai Styleความหมาย
Paginationpaginationแบ่ง result เป็นหน้า — cursor หรือ offset
Filteringfilteringกรอง resource ตาม criteria
Sortingsortingเรียง resource ตาม field
Rate Limitingrate limitingจำกัด request ต่อ time window
Cachingcachingเก็บ response ไว้ใช้ซ้ำ — ลด latency
Versioningversioningจัดการ API evolution โดยไม่ทำให้ consumer พัง
CORSCORSCross-Origin Resource Sharing — ควบคุม cross-domain access
Content Negotiationcontent negotiationclient บอก server ว่าต้องการ format ใด
ETagETagfingerprint ของ resource — ใช้ conditional request
Idempotency Keyidempotency keykey ที่ client ส่งเพื่อทำให้ POST เป็น idempotent
Styleข้อดีข้อเสีย
RESTมาตรฐาน, cacheable, เข้าใจง่ายover/under-fetching ได้
GraphQLflexible query, ดึงเฉพาะที่ต้องการcaching ยากกว่า, complex setup
gRPCเร็ว, type-safe, streaminghuman-readable น้อย, ต้องการ tooling
RPC (JSON)ง่าย, ตรงไปตรงมาtight coupling, ไม่ standard
  • ต้องการ real-time bidirectional — ใช้ WebSocket แทน
  • Heavy binary streaming — gRPC เหมาะกว่า
  • Microservice internal call ที่ต้องการ performance สูง — gRPC หรือ message queue
  • Query ที่ซับซ้อนมาก ต้องการ flexible shape — GraphQL เหมาะกว่า