⚖️ Thai Legal Data API/MCP
Thai law as data, not prose. Look up any มาตรา verbatim, search 39 statutes by meaning, find the Supreme Court decisions that interpret a given section, and ask questions that get answered only from retrieved sources — with every citation machine-checked.
Built for AI agents: the whole surface is also available through the iApp MCP server, so Claude, ChatGPT, Grok, Cursor or any MCP client can research Thai law directly.
What's in the corpus
| Statutes | 39 laws · 6,363 sections — the consolidated text used by OpenThai 2.0 Legal, including ป.พ.พ., ป.อ., ป.วิ.พ., ป.วิ.อ. and ประมวลรัษฎากร |
| Supreme Court decisions | 70,634 rulings with their หลักกฎหมาย (legal principle) headnote |
| Coverage | พ.ศ. 2400s – 2568; searches default to 2540 onward |
| Citation links | 99.7% of rulings are linked to the laws and sections they cite, so you can go from a section to the case law on it |
Endpoints
| Method | Path | Cost |
|---|---|---|
GET | /v3/store/data/thai-legal/meta | free |
GET | /v3/store/data/thai-legal/laws | free |
GET | /v3/store/data/thai-legal/section | 0.1 IC |
GET POST | /v3/store/data/thai-legal/search | 0.1 IC |
GET POST | /v3/store/data/thai-legal/deka/search | 0.1 IC |
GET | /v3/store/data/thai-legal/deka/{case_id} | 0.1 IC |
POST | /v3/store/data/thai-legal/ask | 0.1 IC |
/meta and /laws are free permanently — an agent has to call them to build a valid request, so discovery shouldn't cost anything.
Visit API Key Management to view your key or request a new one.
Try It
Section lookup
Example Queries (Click to try)
Add query parameters (e.g., ?holiday_type=public&days_after=30)
Precedent search (ฎีกา)
Example Queries (Click to try)
Add query parameters (e.g., ?holiday_type=public&days_after=30)
Look up a section
curl "https://api.iapp.co.th/v3/store/data/thai-legal/section?law=ประมวลกฎหมายอาญา§ion=335&with_deka=true" \
-H "apikey: YOUR_API_KEY"
{
"found": true,
"law": "ประมวลกฎหมายอาญา",
"section": "335",
"text": "ผู้ใดลักทรัพย์\n(๑) ในเวลากลางคืน\n...",
"deka": [
{ "case_id": "600/2544", "year_be": 2544,
"headnote": "เมื่อผู้เสียหายเห็นจำเลยทั้งสองกำลังลักเอามะม่วง...",
"official_url": "https://deka.supremecourt.or.th" }
]
}
A miss returns found: false with suggestions — and still HTTP 200, so clients don't retry-loop on a valid-but-unindexed section.
Search precedent
The cites_law + cites_section filter answers the question lawyers actually ask: which ฎีกา interpret this section?
curl -X POST "https://api.iapp.co.th/v3/store/data/thai-legal/deka/search" \
-H "apikey: YOUR_API_KEY" -H "Content-Type: application/json" \
-d '{"query":"ลักทรัพย์ในเวลากลางคืน","cites_law":"ป.อ.","cites_section":"335","top_k":3}'
{
"count": 3,
"results": [
{
"case_id": "600/2544",
"year_be": 2544,
"headnote": "…ถือได้ว่าจำเลยที่ 2 ได้พูดขู่เข็ญผู้เสียหาย…อันเป็นการกระทำความผิดฐานชิงทรัพย์",
"cited": [["ป.อ.", "339"], ["ป.อ.", "335"]],
"citation_join": "exact",
"score": 0.9312,
"official_url": "https://deka.supremecourt.or.th"
}
],
"disclaimer": "ข้อมูลเพื่อการค้นคว้า มิใช่คำแนะนำทางกฎหมาย โปรดตรวจสอบกับต้นฉบับที่ศาลฎีกา"
}
An empty result is a real answer. When nothing matches you get count: 0 and a note saying so — the API never invents a case number to fill the gap.
citation_join tells you how a ruling was linked to its cited sections (exact, range or none), so you can filter to only high-confidence links when accuracy matters more than recall.
Grounded Q&A
/ask retrieves statutes and precedent first, then answers only from what it found.
curl -X POST "https://api.iapp.co.th/v3/store/data/thai-legal/ask" \
-H "apikey: YOUR_API_KEY" -H "Content-Type: application/json" \
-d '{"question":"ลักทรัพย์ในเวลากลางคืนมีโทษอย่างไร","include_deka":true}'
Three guarantees, enforced in code rather than by prompt alone:
- Nothing retrieved → no answer. You get
grounded: falsewithreason: "no_grounding", never a guess from model memory. - Every ฎีกา number in the answer is checked against the retrieved set. If the model cites one that wasn't provided, the answer is regenerated once under a stricter instruction, and refused if it happens again.
- Citations come back structured, so you can render or verify them independently of the prose.
Use it from an AI agent (iapp-mcp)
The whole API ships as six tools in the iApp MCP server (iapp-mcp on PyPI), so Claude Code, Claude Desktop, Cursor or any MCP client can research Thai law directly — no glue code.
Install
One command for Claude Code (requires uv):
claude mcp add iapp-mcp -s user -e IAPP_API_KEY=YOUR_API_KEY -- uvx iapp-mcp
For Claude Desktop, Cursor or any other MCP client, add this to the client's MCP config:
{
"mcpServers": {
"iapp-mcp": {
"command": "uvx",
"args": ["iapp-mcp"],
"env": { "IAPP_API_KEY": "YOUR_API_KEY" }
}
}
}
The server runs locally over stdio — your API key stays on your machine, and only the API calls themselves go out.
The six legal tools
| Tool | Parameters | What it does |
|---|---|---|
iapp_thai_law_list | q (optional name filter) | Catalogue of the 39 indexed laws — free; call it first to get valid law names |
iapp_thai_law_section | law, section, with_deka | Verbatim มาตรา text, e.g. law ประมวลกฎหมายอาญา section 335; with_deka: true adds the Supreme Court decisions citing it |
iapp_thai_law_search | query, top_k (1–20, default 8) | Semantic statute search from a Thai fact pattern |
iapp_thai_deka_search | query, cites_law, cites_section, year_from (default 2540), top_k (default 5) | Precedent search across 70,634 rulings; filter to decisions citing a specific section (court abbreviations, e.g. ป.อ.) |
iapp_thai_deka_get | case_id, include_body | One ruling by ฎีกา number — 1234/2565 and 1234-2565 both accepted; include_body adds up to 4,000 chars of ruling text |
iapp_thai_legal_ask | question, include_deka | Grounded answer with machine-verified citations; refuses instead of guessing when nothing is retrieved |
Example prompts
Once connected, just ask in natural language:
- "ลักทรัพย์ในเวลากลางคืนมีโทษอย่างไร อ้างมาตราและฎีกาให้ด้วย"
- "หาฎีกาที่ตีความ ป.อ. มาตรา 335 หลังปี 2560"
- "Compare ป.พ.พ. 420 and 421 and summarize the case law on each"
Tool calls are billed like the REST API — 0.1 IC per request (free during the launch promotion); iapp_thai_law_list is free permanently.
Sources & licensing
Supreme Court decisions are official court records. Under พ.ร.บ. ลิขสิทธิ์ พ.ศ. 2537 มาตรา 7(4), คำพิพากษา and official reports are not copyright works, so the underlying text is in the public domain.
iApp does not certify these texts on behalf of the court. Every result carries a link back to the official record at deka.supremecourt.or.th — verify there before relying on a ruling in practice. Report an error to legal@iapp.co.th.
Limitations
- The corpus covers rulings that appear in the source dataset; it is not the complete ศาลฎีกา archive.
/metareports exactly what is indexed. - Searches default to พ.ศ. 2540 onward because older rulings cite superseded section numbering. Set
year_fromlower to include them. - Precedent search matches on the headnote (หลักกฎหมาย) — the legal principle — not the full narrative.
/deka/{id}?include=bodyreturns at most 4,000 characters. The API is a retrieval service, not a bulk redistribution of the court's archive.- Not legal advice.
Support
- Email: sale@iapp.co.th · Corrections: legal@iapp.co.th
- Phone: 086-322-5858
- Discord: iApp Technology