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 every interface as a subcommand plus catalog; catalog is the source of truth for the command list, routing rules, and result kind values. Each envelope carries the version that produced it.
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
- Amendment rationale — the 「개정이유 및 주요내용」 text for a specific statute version
- Committee decisions from twelve regulators (개인정보보호위·공정위·금융위·인권위·노동위 등) and 행정심판 재결례 including four special tribunals — the record of an agency applying the law it administers, kept distinct from precedent
- Query expansion, comparable-mechanism discovery, and staged context bundles with executable follow-up lookups
Context budgeting: get-law --toc returns a statute's article map without the text (276KB → 19KB on 개인정보 보호법), --brief returns a decision's 요지 without the full body, and flags.large_payload warns when a narrowing option was available.
Out of scope: legal advice, National Assembly bill data (status, votes, minutes), legislative pre-announcement (입법예고 — a separate 국민참여입법센터 source), and latest statistics/news.
Documentation
Full documentation is in the docs/wiki/ folder:
- Installation · Quickstart · Core Concepts
- CLI Reference · API Reference
- Historical Versions · Sources & Coverage
- Gotchas · Error Handling
- Maintainer Notes
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moleg_api-0.3.0.tar.gz.
File metadata
- Download URL: moleg_api-0.3.0.tar.gz
- Upload date:
- Size: 205.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61e328e8dd207a4de5e5e452dd979130a7ec1a10c73dc853608573230a59c71d
|
|
| MD5 |
12e374c11f65a475bfaa1cce413c1118
|
|
| BLAKE2b-256 |
d7d46ff532b5be185a71e215fa4c17ed878a0f420acb5071f973c3400ee2ebc1
|
Provenance
The following attestation bundles were made for moleg_api-0.3.0.tar.gz:
Publisher:
workflow.yml on tjdwls101010/MOLEG-API
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moleg_api-0.3.0.tar.gz -
Subject digest:
61e328e8dd207a4de5e5e452dd979130a7ec1a10c73dc853608573230a59c71d - Sigstore transparency entry: 2200975953
- Sigstore integration time:
-
Permalink:
tjdwls101010/MOLEG-API@33c72cd18fae1a6394c144f4f2829656707209a2 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/tjdwls101010
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@33c72cd18fae1a6394c144f4f2829656707209a2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file moleg_api-0.3.0-py3-none-any.whl.
File metadata
- Download URL: moleg_api-0.3.0-py3-none-any.whl
- Upload date:
- Size: 189.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c3cc67ebf7fc849ec4151a1110d3df3242f22388dac253e8798b8791896e318
|
|
| MD5 |
19c9bbd83ceac4e0e49d12c26b9bd0e3
|
|
| BLAKE2b-256 |
08b45be8ecf6315c8e709666eb2a84d4a47f25b0861eb175c08fc0d1fcc8d168
|
Provenance
The following attestation bundles were made for moleg_api-0.3.0-py3-none-any.whl:
Publisher:
workflow.yml on tjdwls101010/MOLEG-API
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moleg_api-0.3.0-py3-none-any.whl -
Subject digest:
5c3cc67ebf7fc849ec4151a1110d3df3242f22388dac253e8798b8791896e318 - Sigstore transparency entry: 2200976039
- Sigstore integration time:
-
Permalink:
tjdwls101010/MOLEG-API@33c72cd18fae1a6394c144f4f2829656707209a2 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/tjdwls101010
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@33c72cd18fae1a6394c144f4f2829656707209a2 -
Trigger Event:
release
-
Statement type: