REST API v1 — Pháp luật Việt Nam dưới dạng JSON, CC BY 4.0
10 endpoint REST API mở dưới giấy phép CC BY 4.0 — dùng thương mại được, chỉ cần dẫn nguồn VietLex.vn. Không API key, không quota, không khoá rate. Dữ liệu pháp luật Việt Nam sẵn sàng nhúng vào AI app, RAG pipeline, vector database.
10 endpoint mở
/api/v1Info + danh sách 10 endpoint mở
curl https://vietlex.vn/api/v1
/api/v1/searchTìm văn bản pháp luật: ?q=&loai=&linh_vuc=&dia_phuong=&nam=&kind_group=&limit=&offset=
curl "https://vietlex.vn/api/v1/search?q=doanh+nghiep&loai=Luật&nam=2020"
/api/v1/document/{id}Chi tiết văn bản pháp luật: metadata + effects + pdfHash SHA-256 + download URL
curl https://vietlex.vn/api/v1/document/doc_123456
/api/v1/citator/{id}Tier (red/orange/yellow/green/gray) + inbound/outbound có nhãn + màu
curl https://vietlex.vn/api/v1/citator/doc_123456
/api/v1/effects/{id}Inbound + outbound effects: thay_the / bai_bo / sua_doi / bo_sung / hop_nhat / dinh_chinh
curl https://vietlex.vn/api/v1/effects/doc_123456
/api/v1/timeline/{id}Các sự kiện theo thời gian (ban hành + bị tác động)
curl https://vietlex.vn/api/v1/timeline/doc_123456
/api/v1/linh-vucDanh sách 54 lĩnh vực + slug + count
curl https://vietlex.vn/api/v1/linh-vuc
/api/v1/dia-phuongDanh sách 34 đơn vị hành chính sau sáp nhập 7/2025
curl https://vietlex.vn/api/v1/dia-phuong
/api/file/{path}Tải PDF gốc — stream từ Kho luật, attachment header
curl https://vietlex.vn/api/file/01-Luat/luat-doanh-nghiep-2020.pdf
/api/v1/dumpDump toàn bộ metadata + SHA-256 dạng NDJSON (CC BY 4.0). ~50MB
curl https://vietlex.vn/api/v1/dump -o vietlex-vbpl-dump.ndjson
/api/tro-ly-aiTrợ lý AI POST: { "question": "..." } — RAG top-8 từ Meili + Gemini
curl -X POST https://vietlex.vn/api/tro-ly-ai \
-H "Content-Type: application/json" \
-d '{"question": "Luật Doanh nghiệp 2020 quy định vốn điều lệ thế nào?"}'Build RAG pipeline với dữ liệu VietLex
Tải dump toàn bộ 84.000 văn bản pháp luật (~50MB NDJSON) → embed vector → semantic search trong AI app:
# Build RAG pipeline cho VietLex bằng Python
import requests, json
# 1. Tải dump toàn bộ văn bản pháp luật (~50MB NDJSON)
r = requests.get("https://vietlex.vn/api/v1/dump", stream=True)
with open("vietlex-vbpl.ndjson", "wb") as f:
for chunk in r.iter_content(8192):
f.write(chunk)
# 2. Đọc + embed (vd với OpenAI)
docs = [json.loads(line) for line in open("vietlex-vbpl.ndjson")]
# embed_docs(docs) → vector database (Pinecone / Weaviate / Chroma)
# 3. Khi user hỏi → semantic search → retrieve top-K → gửi vào LLM với context
def answer(question):
relevant_docs = retrieve_topk(question, k=8)
context = "\n\n".join(d["title"] + ": " + d["fulltext"] for d in relevant_docs)
return llm.chat(f"Trả lời theo văn bản pháp luật sau, dẫn link vietlex.vn:\n{context}\n\nCâu hỏi: {question}")
Gọi nhanh từ JavaScript / TypeScript
// JavaScript / TypeScript — gọi API VietLex
const res = await fetch('https://vietlex.vn/api/v1/search?q=' + encodeURIComponent('doanh nghiệp') + '&loai=Luật&nam=2020');
const data = await res.json();
console.log(data.hits[0]);
// → { id, soHieu, loai, title, ngayBanHanh, url: "https://vietlex.vn/van-ban/..." }Điều khoản sử dụng
- Giấy phép Creative Commons BY 4.0 — dùng thương mại OK, chỉ cần dẫn nguồn VietLex.vn.
- Trích dẫn mẫu: “Dữ liệu cung cấp bởi VietLex.vn — Cổng tra cứu pháp luật Việt Nam phi lợi nhuận”.
- văn bản pháp luật gốc thuộc Nhà nước Việt Nam, KHÔNG có quyền tác giả theo Điều 15 khoản 2 Luật SHTT 2005.
- API miễn phí vĩnh viễn. Nếu cần SLA / hỗ trợ doanh nghiệp, liên hệ qua /lien-he.