SDK & CLI
Mã nguồn wrapper REST + GraphQL + MCP. Node, Python và CLI. Lưu tại sdk/ trong repo, CHƯA publish npm/PyPI.
vietlex-sdk
Node.js / TypeScript
npm install vietlex-sdkvietlex (Python)
Python 3.7+
pip install vietlexvietlex-cli
Terminal CLI
npm install -g vietlex-cli📗vietlex-sdk· Node.js / TypeScript
Cài đặt
npm install vietlex-sdkNode.js / TypeScript example
import { VietLex } from 'vietlex-sdk';
const vl = new VietLex();
// Search VBPL
const r = await vl.searchVbpl('luật đấu thầu', { limit: 5, loai: 'Luật' });
console.log(r.total, r.hits);
// GraphQL
const { data } = await vl.graphql(`{
searchVbpl(query:"đất đai", limit:5){
total hits { title url }
}
}`);
// MCP tool call
const tools = await vl.mcp('search_an_le', { query: 'thừa kế' });📦 Source: sdk/node/ trong repo VietLex (local)
Chưa publish npm — cần account.
🐍vietlex (Python)· Python 3.7+
Cài đặt
pip install vietlexPython example
from vietlex import VietLex
vl = VietLex()
# Search VBPL
r = vl.search_vbpl('luật đấu thầu', limit=5, loai='Luật')
for h in r['hits']:
print(h['title'], h['url'])
# GraphQL
data = vl.graphql('{ searchVbpl(query:"thuế", limit:3){ total hits { title url } } }')
# MCP
ale = vl.mcp('search_an_le', {'query': 'thừa kế'})📦 Source: sdk/python/ trong repo VietLex (local)
Chưa publish PyPI — cần account.
⌨️vietlex-cli· Terminal CLI
Cài đặt
npm install -g vietlex-cliTerminal commands
# Search VBPL từ terminal
vietlex search "luật đấu thầu" --limit=5 --loai=Luật
# Get full VBPL
vietlex get doc_xxx
# Search án lệ
vietlex anle "tranh chấp đất đai"
# Search gói thầu
vietlex dauthau "y tế" --provCode=01
# Output JSON
vietlex search "thuế" --format=json | jq '.hits[0]'
# Call MCP tool trực tiếp
vietlex mcp search_vbpl '{"query":"thuế","limit":3}'📦 Source: sdk/cli/ trong repo VietLex (local)
Chưa publish npm.
⚙️ API endpoints SDK gọi vào
- /api/v1/* — REST API gốc (search / document / citator / effects / dump)
- /api/graphql — GraphQL với schema introspection
- /api/mcp — MCP Server JSON-RPC 2.0
- /api/oembed — oEmbed v1.0 cho văn bản pháp luật embed
- /api/webhook — Webhook subscribe (HMAC-SHA256)
- /api/search/semantic — Vector hybrid search (Gemini embeddings)
Mã nguồn SDK (Node + Python + CLI) sẽ publish lên npm + PyPI public sớm. Theo dõi cập nhật tại trang chủ.