# AmLichVietnam Developers

> Free Public API, MCP, and A2A for AI agents. Vietnamese lunar calendar, auspicious days, Zi Wei, BaZi, compatibility, numerology, knowledge.

- HTML docs: https://amlichvietnam.vn/developers
- OpenAPI: https://amlichvietnam.vn/openapi.json
- Auth rules: https://amlichvietnam.vn/auth.md
- English intro: https://amlichvietnam.vn/en

## Audience

AI agents calling **free** features only. Admin / CMS write APIs are **not** available to agents.

Upgrade page: https://amlichvietnam.vn/nang-cap. Paid API plans, HD charts without a watermark, and PDF are sắp ra mắt. The user opens the link and pays on the website. API plans do not include web chat, and web plans do not include API quota.

## Public access (anonymous)

- Base: `https://amlichvietnam.vn/api/public/v1`
- Index: `GET https://amlichvietnam.vn/api/public/v1` (JSON operation list)
- MCP: `https://amlichvietnam.vn/mcp` (Streamable HTTP, 23 tools, Bearer `alv_live_` or mã chat `access_code`, stateless)
- A2A: `https://amlichvietnam.vn/a2a`
- Rate limit: **60 req/min**, **2000 req/day** per IP → 429 + Retry-After
- CORS `*` · `Content-Signal: ai-train=no, search=yes, ai-input=yes`

## MCP quickstart

1. `initialize`
2. `tools/list`
3. `tools/call` (example: `get_lunar_today`)

No `Mcp-Session-Id` required. Send `Authorization: Bearer alv_live_…` when the client allows headers. If it does not, ask the user for a mã chat and pass `access_code`. Example client config:

```json
{
  "mcpServers": {
    "amlichvietnam": {
      "url": "https://amlichvietnam.vn/mcp"
    }
  }
}
```

## MCP tools

- `get_lunar_today`
- `convert_lunar_date`
- `get_lunar_month`
- `find_good_days`
- `check_good_day`
- `get_tuvi_summary`
- `get_bazi_summary`
- `check_age_compatibility`
- `check_build_house_age`
- `get_love_compatibility`
- `get_numerology_summary`
- `get_numerology_compatibility`
- `get_menh_by_year`
- `search_knowledge`
- `list_knowledge_articles`
- `get_knowledge_article`
- `list_knowledge_categories`
- `tuvi_image`
- `good_day_wedding`
- `get_upgrade_link`
- `tuvi_detail`
- `check_quota`
- `save_chart`

## Operations

operationId matches MCP tool name except `health` and `plans` (REST-only).

- `GET /health` — `health`
- `GET /lunar/today` — `get_lunar_today`
- `GET /lunar/convert` — `convert_lunar_date`
- `GET /lunar/month` — `get_lunar_month`
- `GET /good-days` — `find_good_days`
- `GET /good-days/check` — `check_good_day`
- `POST /tu-vi/summary` — `get_tuvi_summary`
- `POST /bat-tu/summary` — `get_bazi_summary`
- `GET /hop-tuoi` — `check_age_compatibility`
- `GET /hop-tuoi/xay-nha` — `check_build_house_age`
- `POST /tinh-duyen/summary` — `get_love_compatibility`
- `POST /than-so/summary` — `get_numerology_summary`
- `POST /than-so/compatibility` — `get_numerology_compatibility`
- `GET /menh` — `get_menh_by_year`
- `GET /knowledge/search` — `search_knowledge`
- `GET /knowledge/articles` — `list_knowledge_articles`
- `GET /knowledge/articles/{category}/{slug}` — `get_knowledge_article`
- `GET /knowledge/categories` — `list_knowledge_categories`
- `POST /tu-vi/image` — `tuvi_image`
- `POST /tu-vi/detail` — `tuvi_detail`
- `GET /me/quota` — `check_quota`
- `GET /charts` — `list_charts`
- `POST /charts` — `save_chart`
- `DELETE /charts/{id}` — `delete_chart`
- `POST /share-links` — `create_share_link`
- `DELETE /share-links/{id}` — `revoke_share_link`
- `GET /good-days/wedding` — `good_day_wedding`
- `GET /upgrade-link` — `get_upgrade_link`
- `GET /plans` — `plans`

### Tham số bắt buộc (tóm tắt)

- `lunar/convert?date=YYYY-MM-DD` (`direction` mặc định solar_to_lunar)
- `good-days`: `category`, `from`, `to`; `good-days/check`: `date`, `category`
- `hop-tuoi`: `year_a`, `year_b`, `purpose`; `hop-tuoi/xay-nha`: `birth_year`, `build_year`
- `menh?birth_year=`
- `tu-vi/summary` body: `{ birth_date, birth_time "HH:mm", gender "nam"|"nu", include_image? }` (`include_image` thêm `image_url` khi API ảnh bật)
- `tu-vi/image` body: `{ birth_date, birth_time, gender, size? "1080"|"2160", theme? "light"|"dark" }` (free luôn 1080 + watermark; 2160 bị hạ và `gated: ["image_hd"]`. HD không watermark sắp ra mắt)
- `good-days/wedding`: `from`, `to`; `bride_birth_year?`, `groom_birth_year?` (hai tuổi → hai danh sách, không có điểm gộp)
- `upgrade-link`: `plan?` (`api_plus` | `api_pro` | `api_topup_1000`), `tool?` — người dùng tự mở link
- `tu-vi/detail` body: `{ birth_date, birth_time, gender, sections?, year?, access_code? }`. Không key hoặc key free → `upgrade_required` (không phải lỗi). Mã chat đi qua `access_code` khi client không gửi được header.
- `GET /me/quota`: cần API key. Trả `plan`, `remaining_month`, `remaining_day`, `reset_at`.
- `POST /charts`: `consent: true` bắt buộc. `api_plus` lưu 20, `api_pro` lưu 200. `GET /charts` liệt kê `id`, `label`, `created_at` (không có ngày giờ sinh). `DELETE /charts/{id}` xóa lá số của key.
- `POST /share-links`: key hoặc phiên web. Free 3 link/tháng. Mặc định ẩn ngày giờ sinh, hạn 90 ngày. `DELETE /share-links/{id}` thu hồi.
- `GET /plans`: giá mặc định. Gói trả phí sắp ra mắt
- `bat-tu/summary` body: `{ birth_date, gender; birth_time? }`
- `than-so/summary` body: `{ full_name, birth_date }`
- `than-so/compatibility` body: `{ a: { full_name, birth_date }, b: { … } }`
- `tinh-duyen/summary` body: `{ a: { birth_date, gender, birth_time? }, b: { … } }`

### Enum

- **good-days category:** cuoi-hoi, khai-truong, dong-tho, xuat-hanh, mua-nha, nhap-trach, cau-an, mua-xe, sinh-con, an-tang
- **hop-tuoi purpose:** vo-chong, lam-an, lay-vo, lay-chong
- **gender:** nam | nu
- **chart image size:** 1080 (free) | 2160 (accepted, downgraded; HD sắp ra mắt)
- **chart image theme:** light | dark
- **upgrade plan:** api_plus | api_pro | api_topup_1000 (sắp ra mắt)

### Lỗi (application/problem+json)

Mọi lỗi API trả `Content-Type: application/problem+json` với `type` dạng `https://amlichvietnam.vn/developers/errors#{code}` (invalid-input, invalid-date, out-of-range, not-found, unauthorized, invalid-key, scope-missing, origin-forbidden, rate-limited, quota-exceeded, …). 401 kèm `WWW-Authenticate: Bearer`. Path không tồn tại dưới `/api/public/v1/*` → 404 problem+json.

## Envelope

200 responses include: `data`, `source` ("AmLichVietnam.vn"), `source_url`, `tool`, `tier` (`free` | `api_plus` | `api_pro`; no key or a free key stays `free`), `method_note`, `upgrade_url` (always, `/nang-cap`), `disclaimer`, `attribution`, `algorithm_version`, `generated_at` (ICT). `quota` is present when a key is sent. `gated` is omitted on the default free response; `POST /tu-vi/image` with `size=2160` returns 1080, `watermark: true`, and `gated: ["image_hd"]` because HD is sắp ra mắt. `tuvi_detail` without a paid key returns `upgrade_required`.

## Example curl

```bash
curl -s "https://amlichvietnam.vn/api/public/v1/lunar/convert?date=2026-02-17&direction=solar_to_lunar"

curl -s -X POST "https://amlichvietnam.vn/api/public/v1/bat-tu/summary" \
  -H "Content-Type: application/json" \
  -d '{"birth_date":"1990-05-15","birth_time":"09:30","gender":"nam"}'
```

### Quy tắc trích dẫn

- Ghi **"Nguồn: AmLichVietnam.vn"** + dùng `source` (`AmLichVietnam.vn`) và `source_url` trong JSON response
- `upgrade_url` luôn có (trang `/nang-cap`). Khi kết quả có `gated` hoặc `upgrade_url`, đưa link để người dùng tự nâng cấp. Không thu thông tin thanh toán. Gói API trả phí sắp ra mắt.
- `tier`: `free` | `api_plus` | `api_pro` (không key hoặc key free thì `free`; gói API tách khỏi gói Plus trên web và không gồm chat web)
- `Content-Signal: ai-train=no, search=yes, ai-input=yes` — được dùng cho search/grounding; không train

### Changelog (agent surface)

- **2026-11-15:** envelope thêm `source`; `upgrade_url` luôn có và trỏ `/nang-cap`; `tier` gồm `free` | `api_plus` | `api_pro`; `quota` chưa trả. `gated` chỉ khi yêu cầu thứ sắp ra mắt (ảnh HD).
- **2026-11-16:** 23 MCP tools, thêm `tuvi_detail`, `check_quota`, `save_chart`. REST `POST /tu-vi/detail`, `GET /me/quota`, `POST /charts`. Free gọi `tuvi_detail` nhận `upgrade_required`. HD, PDF và gói trả phí sắp ra mắt.
- **2026-11-16:** `POST /share-links` và `DELETE /share-links/{id}`. Trang `/q/{token}` là noindex, follow, không có trong sitemap.
- **2026-11-16:** `GET /charts` và `DELETE /charts/{id}`. Lưu lá số cần `consent: true`. Web Free 3 lá số, Web Plus 20.
- **2026-11-15:** 20 MCP tools, thêm `tuvi_image`, `good_day_wedding`, `get_upgrade_link`. REST `POST /tu-vi/image`, `GET /good-days/wedding`, `GET /upgrade-link`, `GET /plans`. Ảnh free 1080 có watermark. HD, PDF và gói trả phí sắp ra mắt.
- **2026-10-31:** llms-full endpoints sync OpenAPI; API index `GET /api/public/v1`; robots Google-Extended Allow docs+SEO; `/docs`→`/developers`; MCP + list_knowledge_categories

## Widget

Paste one script tag. It finds `data-type="lich-am"` or `data-type="ngay-tot"` and creates an iframe. No cookies, no tracking, no requests besides the iframe.

- `lich-am` → `https://amlichvietnam.vn/embed/lich-am`
- `ngay-tot` → `https://amlichvietnam.vn/embed/ngay-tot` (noindex, not in the sitemap)
- `data-theme`: `light` or `dark`

The iframe attribution anchor text is exactly `AmLichVietnam.vn`.

```html
<script src="https://amlichvietnam.vn/widget.js" data-type="ngay-tot" data-theme="light" async></script>
```

## Discovery

- https://amlichvietnam.vn/llms.txt · https://amlichvietnam.vn/llms-full.txt
- https://amlichvietnam.vn/.well-known/api-catalog
- https://amlichvietnam.vn/.well-known/mcp/server-card.json
- https://amlichvietnam.vn/.well-known/agent-card.json
- https://amlichvietnam.vn/.well-known/security.txt
- https://amlichvietnam.vn/developers/errors

## Contact

https://amlichvietnam.vn/lien-he
