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 is designed for applications and agent systems that need normalized legal context without memorizing individual MOLEG OpenAPI target values, identifier rules, or response-shape quirks.

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

This is not a complete wrapper around every law.go.kr endpoint. The public interface is intentionally small and deep: search or plan first, then load the selected legal source text, authority detail, delegated rule context, or annex/form body.

Install

After the package is published:

pip install moleg-api

From a repository checkout:

python -m pip install .

Live law.go.kr calls use an OpenAPI credential called the "OC" — your law.go.kr account's email id. The package ships with a shared default OC, so calls work out of the box with no registration required.

To use your own OC (recommended if you call the API heavily — the shared default funnels all traffic through one credential and can hit law.go.kr rate limits), register at law.go.kr and set it:

export MOLEG_OC="your-law-go-kr-oc"

Resolution order: the oc= argument to LawGoKrClient, then MOLEG_OC (environment or a local .env/.env.local), then the bundled default.

Quick Example

from moleg_api import MolegApi

api = MolegApi()

hits = api.search_laws("자동차관리법", basis="effective", display=5)
selected = hits[0].identity

article = api.get_article(selected, "제26조", basis="effective")
print(article.text)

For broader questions, use a staged bundle and inspect deferred follow-ups:

bundle = api.load_legal_context_bundle(
    query="자동차 방치 처리 기준",
    mode="question",
    budget="standard",
)

for lookup in bundle.deferred:
    if lookup.interface == "load_administrative_rule_context":
        rule_context = api.load_followup(lookup)
        break

Public dataclasses serialize recursively:

payload = bundle.to_dict()                  # omits raw source payloads
debug_payload = bundle.to_dict(include_raw=True)
json_text = bundle.to_json_string()

What It Covers

  • Current and promulgated statutes
  • Statute articles, including moved/deleted article status
  • Supplementary provisions
  • Law history and before/after text comparison
  • Delegated rules and legal hierarchy
  • Administrative rules, notices, directives, and established rules
  • Law and administrative-rule annex/form body loading
  • MOLEG official interpretations and ministry first-instance interpretations
  • Ordinary court cases and Constitutional Court decisions
  • Query expansion and comparable-mechanism discovery
  • Staged context bundles with executable follow-up lookups

Documentation

Consumer-specific notes for a future legislative-expert skill remain in docs/SKILL-INTEGRATION.md and docs/SKILL-AUTHOR-COOKBOOK.md. They are examples of one integration, not the package's general-purpose contract.

Status

The package is alpha (0.1.x). The interface is ready for package-level experimentation, but law.go.kr live behavior can vary by source, credential, and endpoint availability. Treat search results as candidates until selected detail loaders have retrieved source text.

This package is a legal-source loader, not legal advice.

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.1.1.tar.gz (154.5 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.1.1-py3-none-any.whl (70.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moleg_api-0.1.1.tar.gz
  • Upload date:
  • Size: 154.5 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.1.1.tar.gz
Algorithm Hash digest
SHA256 37460b9bc9627d9015d92a2aea1098d714501cacd7d6af2b1442149ea7699aba
MD5 7561c4731fc97bc1a1d425cfafda9d09
BLAKE2b-256 b346624913933c3aa6bdc3a46ae6a2e3b8db8e9d0cbd8669adf4542003851bc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for moleg_api-0.1.1.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.1.1-py3-none-any.whl.

File metadata

  • Download URL: moleg_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 70.8 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b316f295b37df7bbffc7dc381ff368e68ea24467748831f014b7136c09661826
MD5 9b90e0a3def1593d1738469703a2b9c6
BLAKE2b-256 9c84b73cdd1d7d98af2151ddf41018edb96729225ee06378be4d48a920e119d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for moleg_api-0.1.1-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