Lazy Reader
← Trang chủ

API Reference

Thêm bài đọc vào danh sách qua HTTP API.

Base URL https://lazy.naviplus.work
GET /api/articles Public

Lấy danh sách bài đã được thêm qua API (mới nhất lên đầu).

Response

{
  "articles": [
    {
      "id": "art_1746789012345_x8k2m",
      "title": "Tiêu đề bài viết",
      "category": "Danh mục",
      "created_at": "2026-05-09T10:30:00.000Z"
    }
  ]
}

Thử ngay

curl https://lazy.naviplus.work/api/articles
POST /api/articles Cần xác thực

Thêm một bài đọc mới vào danh sách. Bài sẽ xuất hiện ngay trên trang chủ.

Headers

HeaderGiá trịBắt buộc
Content-Typeapplication/json
AuthorizationBearer <API_KEY>

Request body

TrườngKiểuBắt buộcGiới hạn
titlestring200 ký tự
contentstring50.000 ký tự
categorystring50 ký tự

Ví dụ

curl -X POST https://lazy.naviplus.work/api/articles \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <API_KEY>" \
  -d '{
    "title": "Tiêu đề bài viết",
    "content": "Nội dung bài viết đầy đủ ở đây...",
    "category": "Danh mục"
  }'

Response — 201 Created

{
  "id": "art_1746789012345_x8k2m",
  "title": "Tiêu đề bài viết",
  "created_at": "2026-05-09T10:30:00.000Z"
}

Thử ngay

Mã lỗi

HTTPÝ nghĩa
201Tạo thành công
400Thiếu hoặc sai trường dữ liệu
401Sai hoặc thiếu API Key
503Server chưa cấu hình API_KEY hoặc KV binding

Cấu hình server (Cloudflare Pages)

Cần thêm 2 thứ trong Cloudflare Pages → Settings:

1. Environment variable

TênGiá trị
API_KEYChuỗi bí mật tuỳ chọn (dùng làm Bearer token)

2. KV Namespace binding

Vào Workers & Pages → KV → Create namespace → đặt tên lazy_articles.
Sau đó vào Pages project → Settings → KV namespace bindings → Add binding:

Variable nameKV namespace
ARTICLES_KVlazy_articles

Redeploy sau khi thêm binding.