Skip to main content

⚖️ Thai Legal Data API/MCP

0.1 ICper request · FREE during the launch promotion
v1.0 Active Jul 2026 /v3/store/data/thai-legal

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, Cursor or any MCP client can research Thai law directly.

What's in the corpus

Statutes39 laws · 6,363 sections — the consolidated text used by OpenThai 2.0 Legal, including ป.พ.พ., ป.อ., ป.วิ.พ., ป.วิ.อ. and ประมวลรัษฎากร
Supreme Court decisions70,634 rulings with their หลักกฎหมาย (legal principle) headnote
Coverageพ.ศ. 2400s – 2568; searches default to 2540 onward
Citation links99.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

MethodPathCost
GET/v3/store/data/thai-legal/metafree
GET/v3/store/data/thai-legal/lawsfree
GET/v3/store/data/thai-legal/section0.1 IC
GET POST/v3/store/data/thai-legal/search0.1 IC
GET POST/v3/store/data/thai-legal/deka/search0.1 IC
GET/v3/store/data/thai-legal/deka/{case_id}0.1 IC
POST/v3/store/data/thai-legal/ask0.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.

How to get an API Key?

Visit API Key Management to view your key or request a new one.

Try It

Section lookup

Example Queries (Click to try)

?law=ประมวลกฎหมายอาญา&section=335&with_deka=true
Exact section text plus the Supreme Court decisions that cite it
?law=ประมวลกฎหมายแพ่งและพาณิชย์&section=420
Wrongful act — the foundation of Thai tort law
?law=ประมวลกฎหมายอาญา&section=326&with_deka=true
Criminal defamation with citing precedent

Add query parameters (e.g., ?holiday_type=public&days_after=30)

Precedent search (ฎีกา)

Example Queries (Click to try)

?query=ลักทรัพย์ในเวลากลางคืน&cites_law=ป.อ.&cites_section=335&top_k=3
Precedent search filtered to rulings that cite a specific section
?query=ผิดสัญญาจะซื้อจะขายที่ดิน&top_k=5
Semantic search over the หลักกฎหมาย headnotes
?query=หมิ่นประมาทออนไลน์&year_from=2560&top_k=5
Restrict results to พ.ศ. 2560 onward

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=ประมวลกฎหมายอาญา&section=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:

  1. Nothing retrieved → no answer. You get grounded: false with reason: "no_grounding", never a guess from model memory.
  2. 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.
  3. 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.

ToolParametersWhat it does
iapp_thai_law_listq (optional name filter)Catalogue of the 39 indexed laws — free; call it first to get valid law names
iapp_thai_law_sectionlaw, section, with_dekaVerbatim มาตรา text, e.g. law ประมวลกฎหมายอาญา section 335; with_deka: true adds the Supreme Court decisions citing it
iapp_thai_law_searchquery, top_k (1–20, default 8)Semantic statute search from a Thai fact pattern
iapp_thai_deka_searchquery, 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_getcase_id, include_bodyOne ruling by ฎีกา number — 1234/2565 and 1234-2565 both accepted; include_body adds up to 4,000 chars of ruling text
iapp_thai_legal_askquestion, include_dekaGrounded 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.thverify 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. /meta reports exactly what is indexed.
  • Searches default to พ.ศ. 2540 onward because older rulings cite superseded section numbering. Set year_from lower to include them.
  • Precedent search matches on the headnote (หลักกฎหมาย) — the legal principle — not the full narrative.
  • /deka/{id}?include=body returns at most 4,000 characters. The API is a retrieval service, not a bulk redistribution of the court's archive.
  • Not legal advice.

Support