Skip to main content

Task-level Python interface for loading Korean legal sources from law.go.kr

Project description

moleg-api

moleg-api is a task-level Python interface for loading Korean legal sources from law.go.kr. It normalizes the Ministry of Government Legislation (법제처) OpenAPI so applications and agents can retrieve legal context without memorizing individual target values, identifier rules (ID, MST, LID, JO), or per-endpoint response quirks.

You pick an interface by the legal task you need — search a statute, load an article, trace an amendment, find a delegated rule, read a Constitutional Court decision — not by a raw endpoint name. It is not a complete wrapper around every law.go.kr endpoint; the public interface is intentionally small and deep. The recurring pattern is search or plan first, then load the selected source: search hits are candidates, not citable text.

The PyPI package is moleg-api; import it as moleg_api.

Install

pip install moleg-api

Live calls use a law.go.kr OpenAPI credential (the "OC" — a free, non-secret account id). The package ships a shared default, so calls work out of the box with no registration required. To use your own OC (recommended for heavy use), register at law.go.kr and set MOLEG_OC, or pass oc= to LawGoKrClient. See Installation.

Quickstart

Python — search, then load the chosen candidate:

from moleg_api import MolegApi

api = MolegApi()
hits = api.search_laws("주택임대차보호법")        # candidate identities
article = api.get_article(hits[0].identity, "제3조")  # loaded source text
print(article.text)

Shell — every method is also a moleg subcommand printing one JSON envelope:

python -m moleg_api catalog                          # self-documenting command list
python -m moleg_api search-laws "주택임대차보호법"    # → candidates with law_id
python -m moleg_api get-article --law 001248 제3조    # load the current article
python -m moleg_api get-article --law 001248 --as-of 2021-01-01 제3조  # the version in force then

The CLI exposes 27 task subcommands plus catalog; catalog is the source of truth for the command list, routing rules, and result kind values.

Public dataclasses serialize recursively with to_dict() / to_json_string() (raw payloads omitted unless include_raw=True).

What it covers

  • Current (effective) and promulgated (promulgated) statutes and articles, including moved/deleted status
  • Supplementary provisions (부칙), law history, and before/after text comparison
  • Historical versions — load the text in force on a past date with as_of
  • Delegated rules, legal hierarchy, and administrative rules (고시·훈령·예규)
  • Law and administrative-rule annex/form bodies (별표·서식)
  • MOLEG and ministry legal interpretations, Supreme Court cases, and Constitutional Court (헌재) decisions
  • Query expansion, comparable-mechanism discovery, and staged context bundles with executable follow-up lookups

Out of scope: legal advice, National Assembly bill data (status, votes, minutes), and latest statistics/news.

Documentation

Full documentation is in the wiki/ folder:

Status

Alpha (0.2.x). The interface is ready for use, but law.go.kr live behavior can vary by source, credential, and endpoint availability. Treat search results as candidates until a detail loader has retrieved source text. This package is a legal-source loader, not legal advice.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moleg_api-0.2.4.tar.gz (171.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moleg_api-0.2.4-py3-none-any.whl (165.6 kB view details)

Uploaded Python 3

File details

Details for the file moleg_api-0.2.4.tar.gz.

File metadata

  • Download URL: moleg_api-0.2.4.tar.gz
  • Upload date:
  • Size: 171.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for moleg_api-0.2.4.tar.gz
Algorithm Hash digest
SHA256 bccc27461f97efb8df5d0d48df0ef26495531a4ba6a662a59f67fdb577936d4a
MD5 ff22c850620ef76c7ccd7fa2017825f4
BLAKE2b-256 c4a11c01bee2cf6b5f159ee420330cb271a796bf95b96c13dd31e0eb12c47bbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for moleg_api-0.2.4.tar.gz:

Publisher: workflow.yml on tjdwls101010/MOLEG-API

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file moleg_api-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: moleg_api-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 165.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for moleg_api-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c537dc5a4f7cf53f5ea8c53800211cc4f34232ce2f4b63bbd2b3527fe8aed28f
MD5 10e47a8ddcfadb5db1155a10796f5a2e
BLAKE2b-256 043680063a29c52cd318d71cbdfcb89b03814e76652f4885014dc34c7cbbc52d

See more details on using hashes here.

Provenance

The following attestation bundles were made for moleg_api-0.2.4-py3-none-any.whl:

Publisher: workflow.yml on tjdwls101010/MOLEG-API

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page