📱 Học IELTS miễn phí: App IELTS 6.0

Giới thiệu

API Documentation là cầu nối giữa người viết API và người sử dụng API. Cho dù bạn là backend developer viết docs cho team frontend, hay là người integrate third-party API — bạn đều cần đọc và viết API docs bằng tiếng Anh.

Thực tế: 99% API documentation trên thế giới viết bằng tiếng Anh. Stripe, Twilio, GitHub, AWS — tất cả đều English. Nếu bạn không đọc được API docs, bạn sẽ mất hàng giờ để hiểu một endpoint đơn giản.

Bài viết này giúp bạn:

  • Nắm từ vựng API quan trọng nhất (có IPA phiên âm)
  • Hiểu cấu trúc chuẩn của API Documentation
  • Đọc được docs từ Stripe, GitHub, Swagger — các API phổ biến
  • Tự tin viết API docs cho project của mình

1. Từ vựng cơ bản — API Fundamentals

#Thuật ngữPhiên âm (IPA)Nghĩa tiếng Việt
1API (Application Programming Interface)/ˌeɪ.piːˈaɪ/Giao diện lập trình ứng dụng
2Endpoint/ˈend.pɔɪnt/Điểm cuối — URL cụ thể của API
3Request/rɪˈkwest/Yêu cầu — dữ liệu gửi đến server
4Response/rɪˈspɒns/Phản hồi — dữ liệu server trả về
5HTTP Method/ˌeɪtʃ.tiː.tiːˈpiː ˈmeθ.əd/Phương thức HTTP (GET, POST, PUT, DELETE)
6Status Code/ˈsteɪ.təs kəʊd/Mã trạng thái — 200 OK, 404 Not Found…
7Header/ˈhed.ər/Tiêu đề — metadata đi kèm request/response
8Body/ˈbɒd.i/Thân — dữ liệu chính của request/response
9Query parameter/ˈkwɪə.ri pəˈræm.ɪ.tər/Tham số truy vấn — ?key=value trên URL
10Path parameter/pɑːθ pəˈræm.ɪ.tər/Tham số đường dẫn — /users/{id}

Ví dụ: Đọc một API endpoint

GHBPEQETaanuTTstdePehpr/oyaMUpipeRanpitLrta/h:a:rvoma2dem/:teuetsree:rrss:/{G/{/suEauutsTpssaeieetr/rruIvIssd2d/=}}{p/ueo=snreddIrieDInrdgsc},?/saoltriaudmtseiuertsrs==1p0ending&limit=10

Giải thích cho team:

“This endpoint accepts a GET request with a path parameter for the user ID. You can filter results using query parameters like status and limit.”


2. Từ vựng nâng cao — Authentication & Data Format

#Thuật ngữPhiên âm (IPA)Nghĩa tiếng Việt
11Authentication/ɔːˌθen.tɪˈkeɪ.ʃən/Xác thực — chứng minh bạn là ai
12Authorization/ˌɔː.θər.aɪˈzeɪ.ʃən/Phân quyền — bạn được làm gì
13Bearer token/ˈbeə.rər ˈtəʊ.kən/Token mang theo — dùng trong header Authorization
14API key/ˌeɪ.piːˈaɪ kiː/Khóa API — chuỗi ký tự xác thực
15Rate limiting/reɪt ˈlɪm.ɪ.tɪŋ/Giới hạn tốc độ — số request tối đa/thời gian
16Payload/ˈpeɪ.ləʊd/Tải trọng — dữ liệu chính trong request body
17Schema/ˈskiː.mə/Lược đồ — cấu trúc dữ liệu (fields, types)
18Pagination/ˌpædʒ.ɪˈneɪ.ʃən/Phân trang — chia kết quả thành nhiều trang
19Webhook/ˈweb.hʊk/Hook web — server gọi ngược đến URL của bạn
20Idempotent/ˌaɪ.dɪmˈpəʊ.tənt/Lũy đẳng — gọi nhiều lần cho cùng kết quả

Authentication trong docs — cách đọc

AAITRulnoatlcAt---hlugeeAuteFPEnPdhnLrrntIeoeieotirrmeecrtiaitraehztttiptqeaesieriut:erioetiar:snsoon:etkn1:se:A1,nP00UrBI00neie0lqnakriureermiteyqeirhr,uqteeeueygsedaAootsuuustttrt/shh_om/eoaimnrpSnitiieuniz_ttucattetatoietiknioegonnsn_hh>veeiarAadePeIBre:Kaeryesr>toCkreena.teNewKey.

Bạn cần làm:

  1. Đọc phần Authentication trước tiên
  2. Lấy API key hoặc Bearer token
  3. Thêm vào Header của mọi request
  4. Chú ý Rate limiting để không bị block

3. Cấu trúc chuẩn của API Documentation

Mỗi API endpoint thường được document theo cấu trúc:

3.1 Endpoint Reference Template

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
## Create a new order

Creates a new order for the specified user.

**Endpoint:** `POST /api/v2/users/{userId}/orders`

### Path Parameters

| Parameter | Type   | Required | Description          |
|-----------|--------|----------|----------------------|
| userId    | string | Yes      | The unique user ID   |

### Request Headers

| Header        | Value              | Required | Description        |
|---------------|--------------------|----------|--------------------|
| Authorization | Bearer {token}     | Yes      | API authentication |
| Content-Type  | application/json   | Yes      | Request body format|

### Request Body

| Field     | Type    | Required | Description                    |
|-----------|---------|----------|--------------------------------|
| productId | string  | Yes      | ID of the product to order     |
| quantity  | integer | Yes      | Number of items (min: 1)       |
| notes     | string  | No       | Optional order notes           |
| coupon    | string  | No       | Discount coupon code           |

### Example Request

    curl -X POST https://api.example.com/api/v2/users/usr_123/orders \
      -H "Authorization: Bearer sk_live_xxx" \
      -H "Content-Type: application/json" \
      -d '{
        "productId": "prod_456",
        "quantity": 2,
        "notes": "Gift wrap please"
      }'

### Response

**Status: 201 Created**

    {
      "id": "ord_789",
      "userId": "usr_123",
      "productId": "prod_456",
      "quantity": 2,
      "status": "pending",
      "createdAt": "2026-03-14T10:30:00Z"
    }

### Error Responses

| Status | Code              | Description               |
|--------|-------------------|---------------------------|
| 400    | invalid_request   | Missing required fields   |
| 401    | unauthorized      | Invalid or expired token  |
| 404    | user_not_found    | User ID does not exist    |
| 429    | rate_limit        | Too many requests         |

3.2 Các phần quan trọng cần đọc

PhầnTiếng AnhĐọc khi nào
OverviewTổng quanĐọc đầu tiên — hiểu API làm gì
AuthenticationXác thựcĐọc ngay — cần để gọi API
EndpointsĐiểm cuốiĐọc endpoint bạn cần dùng
ParametersTham sốXem required fields
ResponsePhản hồiXem data structure trả về
Error codesMã lỗiBookmark — dùng khi debug
Rate limitsGiới hạnĐọc trước khi implement
ChangelogNhật ký thay đổiĐọc khi upgrade version

4. Từ vựng khi viết API Documentation

#Thuật ngữPhiên âm (IPA)Nghĩa tiếng Việt
21Deprecated/ˈdep.rɪ.keɪ.tɪd/Ngừng hỗ trợ — sẽ bị xóa trong tương lai
22Breaking change/ˈbreɪ.kɪŋ tʃeɪndʒ/Thay đổi phá vỡ — không tương thích ngược
23Versioning/ˈvɜːr.ʒən.ɪŋ/Quản lý phiên bản — v1, v2…
24SDK (Software Development Kit)/ˌes.diːˈkeɪ/Bộ công cụ phát triển
25Sandbox/ˈsænd.bɒks/Môi trường thử nghiệm
26Required/rɪˈkwaɪəd/Bắt buộc — field phải có
27Optional/ˈɒp.ʃən.əl/Tùy chọn — có thể bỏ qua
28Nullable/ˈnʌl.ə.bəl/Cho phép null
29Enum/ˈiː.nʌm/Danh sách giá trị cho phép
30Callback/ˈkɔːl.bæk/Gọi lại — URL server sẽ gọi đến

Ví dụ: Viết docs cho API của bạn

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# OpenAPI 3.0 Specification
openapi: 3.0.3
info:
  title: User Management API
  description: API for managing users and their profiles.
  version: 2.1.0

paths:
  /users/{userId}:
    get:
      summary: Get user by ID
      description: |
        Returns a single user object. Requires authentication.
        **Note:** This endpoint is rate-limited to 100 req/min.
      parameters:
        - name: userId
          in: path
          required: true
          description: Unique identifier of the user
          schema:
            type: string
            example: "usr_abc123"
      responses:
        '200':
          description: User found successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '404':
          description: User not found

components:
  schemas:
    User:
      type: object
      required:
        - id
        - email
      properties:
        id:
          type: string
          description: Unique user ID
        email:
          type: string
          format: email
          description: User's email address
        name:
          type: string
          nullable: true
          description: Display name (optional)
        role:
          type: string
          enum: [admin, editor, viewer]
          description: User's role in the system
        createdAt:
          type: string
          format: date-time

5. Mẫu câu giao tiếp về API Documentation

5.1 Khi đọc docs và cần hỏi

Tình huốngCâu tiếng AnhNghĩa
Không hiểu endpoint“What’s the expected payload for this endpoint?”Payload mong đợi cho endpoint này là gì?
Thiếu docs“Is there documentation for the webhook events?”Có docs cho các webhook events không?
API lỗi“I’m getting a 401 Unauthorized. Is the bearer token format correct?”Tôi bị lỗi 401. Format bearer token đúng chưa?
Rate limit“What are the rate limits for the free tier?”Rate limit của free tier là bao nhiêu?

5.2 Khi viết docs cho team

Tình huốngCâu tiếng AnhNghĩa
Thêm endpoint mới“I’ve added docs for the new endpoint. Please review the request schema.”Tôi đã thêm docs cho endpoint mới. Hãy review request schema.
Deprecate API“The v1 endpoint is now deprecated. Please migrate to v2 by June.”Endpoint v1 đã deprecated. Hãy migrate sang v2 trước tháng 6.
Breaking change“Heads up: this is a breaking change. The status field is now an enum instead of a free string.”Lưu ý: đây là breaking change. Field status giờ là enum thay vì string tự do.
Cập nhật docs“Updated the API reference with the new pagination parameters.”Đã cập nhật API reference với các tham số pagination mới.

6. HTTP Status Codes — Developer phải nhớ

CodeTênNghĩaKhi nào gặp
200OKThành côngRequest xử lý thành công
201CreatedĐã tạoPOST tạo resource mới thành công
204No ContentKhông có nội dungDELETE thành công, không trả data
400Bad RequestYêu cầu saiThiếu field, sai format
401UnauthorizedChưa xác thựcToken sai hoặc hết hạn
403ForbiddenBị cấmKhông có quyền truy cập
404Not FoundKhông tìm thấyURL hoặc resource không tồn tại
409ConflictXung độtDuplicate data
422Unprocessable EntityKhông xử lý đượcValidation failed
429Too Many RequestsQuá nhiều yêu cầuVượt rate limit
500Internal Server ErrorLỗi serverBug phía server
502Bad GatewayGateway lỗiServer upstream không phản hồi
503Service UnavailableDịch vụ không khả dụngServer đang bảo trì

7. Practice — Bài tập thực hành

Bài 1: Đọc API Documentation

Đọc đoạn API docs sau và trả lời câu hỏi:

#PTEHPRERNti#ehneaeraoifridaAXtusr444ttmDmspdu-hspo000eeeteaoetCeor134:shlnairhoPrnsLeeecnsonaIs:UFNiTwtntt:rfrdenoomhiueti:iia:artiitslozrm(ubtsheaynDames2tiF:rEt-tt0hdoetudiLiDer4odu1nhhsesEoeriren0deaelTnlsnNindpsreiE:e:gozrostrt,eeiaaer/BeCdqnmlseae:roIUutervpaennseeaeirtqtsesiuar/erueIurtssdusvruinnfseysi2ertvfd/ireb/{eaiomdIbrlut(dlceiedeesor)iisnmea.ekedeupwnnreqnntoidsnuttoetld/}iTotelea{rhkpnllu(eeeeetnelsrdnrx.otee)umitearqsisCdsIuestap.sdirslro}r'ilocesoididnnua)usgctneeiidqtaundemauetilradtr.eionprtliefier

Câu hỏi:

  1. HTTP Method nào được sử dụng?
  2. Header nào bắt buộc ngoài Authorization?
  3. Response trả về status code gì khi thành công?
  4. Tại sao docs nói endpoint này là idempotent?
  5. Rate limit là bao nhiêu?

Bài 2: Viết API Documentation

Viết docs cho endpoint sau bằng tiếng Anh:

  • Chức năng: Cập nhật thông tin profile user
  • Method: PUT
  • URL: /api/v2/users/{userId}/profile
  • Body: name (string, optional), avatar (string/URL, optional), bio (string, max 500 chars, optional)
  • Response: 200 với user object đã cập nhật
  • Lỗi: 400, 401, 404

Bài 3: Điền từ vựng

  1. “The API returns a 429 status code because we hit the _____.”
  2. “This field is _____ — you can set it to null or omit it entirely.”
  3. “The v1 endpoint is _____. Please use v2 instead.”
  4. “Send your API key in the _____ header as a Bearer token.”
  5. “The role field only accepts values from a predefined _____: admin, editor, or viewer.”

Đáp án

Bài 1

  1. DELETE
  2. X-Confirm-Delete: true
  3. 204 No Content
  4. Vì gọi nhiều lần với cùng userId sẽ không gây lỗi — nếu user đã bị xóa, API không trả error
  5. 10 requests/minute

Bài 3

  1. rate limit
  2. nullable (hoặc optional)
  3. deprecated
  4. Authorization
  5. enum

Kết luận

Đọc và viết API Documentation là kỹ năng sống còn cho developer. Với 30 từ vựng trong bài này, bạn đã có đủ nền tảng để:

  • ✅ Đọc hiểu API docs của Stripe, GitHub, AWS — bất kỳ API nào
  • ✅ Viết docs rõ ràng cho API của project mình
  • ✅ Giao tiếp với team về API design một cách chuyên nghiệp
  • ✅ Debug API errors nhanh hơn nhờ hiểu status codes

Tip thực tế: Khi integrate một API mới, đọc theo thứ tự: Overview → Authentication → Endpoint bạn cần → Error codes. Đừng đọc toàn bộ docs — chỉ đọc phần bạn cần dùng! 📚


Bạn thấy bài viết hữu ích? Hãy chia sẻ cho đồng nghiệp developer cùng học nhé!