⚖️ Thai Legal Data API/MCP
Thai law as data, not prose.
Ask a question in plain Thai and get the actual มาตรา back — verbatim, with the Supreme Court decisions that interpret it. No scraping, no PDFs, no maintaining your own corpus.
Who this is for: developers building legal tools, and anyone who wants Claude or ChatGPT to answer Thai legal questions from real sources instead of from memory.
The four things it does
| I want to… | Call | Example |
|---|---|---|
| Read one section I can name | /section | ป.อ. มาตรา 335 → the verbatim text |
| Find the right section from a fact pattern | /search | "เลิกจ้างต้องจ่ายค่าชดเชยเท่าไร" → พ.ร.บ.คุ้มครองแรงงาน ม.118 |
| Find the ฎีกา that interpret a section | /deka/search | which rulings cite ป.อ. 335? |
| Get an answer with citations | /ask | a written answer, or a refusal — never a guess |
Everything else on this page is detail on those four.
Try it right here
No key needed — these boxes call the live API.
Look up a section
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)
Quickstart
Get a key from API Key Management, then:
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",
"unit": "มาตรา",
"chapter": "หมวด ๑ ความผิดฐานลักทรัพย์และวิ่งราวทรัพย์",
"in_force": "curated",
"text": "ผู้ใดลักทรัพย์\n(๑) ในเวลากลางคืน\n...",
"deka": [
{ "case_id": "600/2544", "year_be": 2544,
"headnote": "เมื่อผู้เสียหายเห็นจำเลยทั้งสองกำลังลักเอามะม่วง...",
"official_url": "https://deka.supremecourt.or.th" }
]
}
That is the whole pattern: pass law and section, get the text. A section we do not hold
returns found: false with suggestions — and still HTTP 200, so your client does not
retry-loop on a valid-but-unindexed section.
Finding sections when you don't know the number
curl -X POST "https://api.iapp.co.th/v3/store/data/thai-legal/search" \
-H "apikey: YOUR_API_KEY" -H "Content-Type: application/json" \
-d '{"query":"นายจ้างเลิกจ้างลูกจ้างต้องจ่ายค่าชดเชยเท่ าไร"}'
Results are 600-character snippets so they stay small in an LLM context. When you have
picked the right one, fetch its full text with /section.
Finding the case law on a section
cites_law + cites_section 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}'
Each result carries citation_join — exact, range or none — telling you how confidently
the ruling was linked to the section, so you can filter for precision over recall.
Asking a question
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}'
/ask retrieves first and answers only from what it found. Three guarantees, enforced in
code rather than by prompt:
- Nothing retrieved → no answer.
grounded: false, never a guess from model memory. - Every ฎีกา number is checked against what was retrieved. A citation that was not provided gets the answer regenerated once under stricter instruction, then refused.
- Citations come back structured, so you can verify them without parsing 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.
Connect — the new way (one URL, no API key)
Add the remote MCP server and sign in with your iApp account. No key to copy:
https://mcp.iapp.co.th
- Claude (claude.ai / Desktop): Settings → Connectors → Add custom connector → Name
iApp AI, paste the URL → Connect - Claude Code:
claude mcp add --transport http iapp-ai https://mcp.iapp.co.th - Antigravity (Gemini): Agent panel → MCP servers → add
{ "iapp-ai": { "serverUrl": "https://mcp.iapp.co.th" } } - Cursor / Codex / Windsurf and any MCP client — see the per-client setup guide
Or install locally (classic)
One command for Claude Code (requires uv):
claude mcp add iapp-mcp -s user -e IAPP_API_KEY=YOUR_API_KEY -- uvx iapp-mcp
Or in any client's MCP config:
{
"mcpServers": {
"iapp-mcp": {
"command": "uvx",
"args": ["iapp-mcp"],
"env": { "IAPP_API_KEY": "YOUR_API_KEY" }
}
}
}
The local server runs 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 all 2,346 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 search across 68,235 sections from a Thai fact pattern; warns instead of guessing when the governing law is not indexed |
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.
What it will not do
This is the part most legal AI leaves out, so it is stated plainly.
It tells you when the law you need is missing. Ask about a law outside the corpus and you get the name of the law that governs your question, instead of the closest thing we happen to hold:
{
"coverage": {
"status": "governing_law_not_indexed",
"law": "พระราชบัญญัติ…",
"message_en": "This question is governed by \"…\", which is NOT in the iApp corpus."
}
}
It withholds weak matches. Below a confidence floor you get count: 0 and a confidence
note — not plausible-looking filler.
It never claims a section is in force. Every section carries in_force, and "in force" is
deliberately not one of its values:
| value | meaning |
|---|---|
curated | in the 39-law core |
repealed | krisdika marks it ยกเลิก — 298 laws, kept out of search, still readable via /section |
unverified | everything else |
unverified means exactly that. krisdika has not marked every superseded act —
พ.ร.บ.ยาเสพติดให้โทษ พ.ศ. 2522 carries no marker despite being repealed by
ประมวลกฎหมายยาเสพติด พ.ศ. 2564 — so an absent marker proves nothing.
Check a section is still in force before relying on it.
Other limits
- The ฎีกา corpus is not the complete ศาลฎีกา archive.
/metareports exactly what is indexed. - Precedent search matches the headnote (หลักกฎหมาย), not the full narrative.
- Searches default to พ.ศ. 2540 onward; older rulings cite superseded numbering. Lower
year_fromto include them. /deka/{id}?include=bodyreturns at most 4,000 characters — this is a retrieval service, not a bulk copy of the court's archive.- ศาลปกครอง and ความเห็นกฤษฎีกา are not covered at all.
- Not legal advice.
What's in the corpus
| Statutes | 2,346 laws · 68,235 sections — the five codes, พ.ร.บ., พ.ร.ก., พ.ร.ฎ. and กฎกระทรวง. Includes แรงงาน, ที่ดิน, PDPA, คอมพิวเตอร์, ยาเสพติด, จราจร, ประกันสังคม, ล้มละลาย, ทรัพย์สินทางปัญญา and รัฐธรรมนูญ 2560 |
| Curated core | 39 of those are the consolidated text used by OpenThai 2.0 Legal — ป.พ.พ., ป.อ., ป.วิ.พ., ป.วิ.อ., ประมวลรัษฎากร and the securities set. Preferred over any other copy |
| Supreme Court decisions | 70,634 rulings with their หลักกฎหมาย headnote |
| Coverage | Statutes พ.ศ. 2417–2569 · rulings พ.ศ. 2400s–2568 |
| Citation links | 99.7% of rulings link to the sections they cite, so you can go from a มา ตรา to its case law |
Live figures are always at /meta,
which also lists what is missing.
Endpoint reference
| 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 must call them to build a valid request, so
discovery should not cost anything. /laws?law=<name> returns every section number in a law.
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.
Support
- Email: sale@iapp.co.th · Corrections: legal@iapp.co.th
- Phone: 086-322-5858
- Discord: iApp Technology