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. |