--- name: supreme-court-judgments description: Query the Supreme Court's public server-rendered judgment search by case number, date, proceeding type, annotation, or text. module: riigikohus.mjs execution: get --- # Supreme Court Judgments ## Access - Supreme Court page: `https://www.riigikohus.ee/et/lahendid` - Search endpoint embedded by that page: `GET https://rikos.rik.ee/` - Public HTML; no login or browser automation is required. ## Retrieve Send search fields as query parameters. The short parameter names accepted by the public form include: - `asjaNr`: case number - `asjaLiigidIds`: case type classifier, repeat for multiple values - `syyteoLiigidIds`: offence type classifier - `otsuseKpalgus`, `otsuseKpLopp`: decision date range - `annotatsioon`: annotation text - `tekst`: full-text term - `pageSize`: 1-100 - `sortVaartus`: `LahendiKuulutamiseAeg` or `Menetlus.MenetluseNR` - `sortAsc`: `true` or `false` For example, `?tekst=pohiseadus&pageSize=25` returns matching rows. Follow `/LahendiOtsingEriVaade?asjaNr=...` for the decision view. Add `genereeriPdf=True` to the same search query for the site's result-list PDF. ## Return - `supremeCourtSearch()` rows are `{case, date, kind, subject, url, textUrl}`; `supremeCourtCase()` documents use the same shape. - `textUrl` is the judgment's FULL TEXT: the site prints a `failObjektId` in its last column without linking it, and that id resolves on Riigi Teataja as `/public-api/api/v1/kohtuteave/kohtulahendid//file`. Read it with `fileText(textUrl)`; do not summarize a holding from the result-list `subject`, which is the case caption. ## Limits - This search is Supreme Court-specific. Use `court-proceedings-data` for all court levels and public hearing listings. - **The search does not fold Estonian diacritics.** `tekst=pohiseadus` matches 1 judgment where `tekst=põhiseadus` matches 335 (checked 2026-08-01). A small count here usually means the term was mistyped, not that the court has been silent. - Paging is `lk`, 1-based. `page`, `pageNumber`, `pageIndex` and `leht` are silently ignored and return page one again. - A case number the register does not hold answers a real HTTP 404, not an empty table. The case view wants the case (`5-26-5`), not the document (`5-26-5/14`). ```probe-limit claim A case number the register does not hold answers a real HTTP 404 GET https://rikos.rik.ee/LahendiOtsingEriVaade?asjaNr=5-26-99999 expect-status 404 expect /Viga 404/ # The control is the SAME route with a case number the register does hold, so # the 404 is pinned to the case number and not to the case view having gone # away. A dead route would 404 for every number and "confirm" this forever. control GET https://rikos.rik.ee/LahendiOtsingEriVaade?asjaNr=5-26-5 ``` - Search results are HTML, not JSON. Parse the result table and resolve relative links against `https://rikos.rik.ee/`. - Some judgments are redacted or not publicly available. ## Verify - Require a focused text query to return a positive `Tulemused` count and rows with `/LahendiOtsingEriVaade?asjaNr=` links. - Confirm that the Supreme Court page still embeds `https://rikos.rik.ee/`; reject unrelated files linked elsewhere on the page as judgment results. ## Module API supremeCourtSearch({text, caseNumber, annotation, from, to, year, kind, pageSize, page, ascending}) -> {source, page, query, totals, rows, note} supremeCourtCase(caseNumber) -> {source, page, found, case, subject, totals, documents, note}