Search · API Reference

API — Search

Tài liệu các endpoint của module search. Mỗi endpoint có request format, response format, lỗi có thể xảy ra và ví dụ thực tế.

Tóm tắt endpoint

MethodPathMô tảAuthRate limit
GET/api/v1/search/postsSearch posts.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/search/usernameSearch users.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/search/topicSearch topics.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.

GET /api/v1/search/posts

GET Auth required apiLimiter

Endpoint này dùng để search posts. Gọi endpoint này khi client cần thao tác đúng phạm vi module search.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/search/posts \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "search",
    "endpoint": "/api/v1/search/posts"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/search/username

GET Auth required apiLimiter

Endpoint này dùng để search users. Gọi endpoint này khi client cần thao tác đúng phạm vi module search.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/search/username \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "search",
    "endpoint": "/api/v1/search/username"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/search/topic

GET Auth required apiLimiter

Endpoint này dùng để search topics. Gọi endpoint này khi client cần thao tác đúng phạm vi module search.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/search/topic \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "search",
    "endpoint": "/api/v1/search/topic"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú