Skip to main content

kr-law-extractor

법제처 OpenAPI에서 한국 법령 조문을 수집하여 Silver 레이어 포맷의 JSON 파일로 저장하는 Python 패키지입니다.

설치

pip install kr-law-extractor

사용법

from law_extractor import extract

# 법령명 리스트 → JSON 파일 생성
files = extract(
    ["소득세법", "국세기본법", "근로기준법"],
    output_dir="./output",
    oc="your-oc-key",   # 법제처 API OC 키
)
# ./output/소득세법.json, ./output/국세기본법.json, ... 생성

환경변수로 OC 키를 설정할 수도 있습니다:

export LAW_OC="your-oc-key"
from law_extractor import extract

extract(["소득세법"], output_dir="./output")  # oc 파라미터 생략 가능

출력 포맷

각 법령마다 {법령명}.json 파일이 생성됩니다. 파일 내용은 조문(Article) 단위 레코드의 배열입니다:

[
  {
    "law_mst": "001565",
    "jo_number": "000001",
    "jo_branch_number": null,
    "law_name_ko": "소득세법",
    "law_category": "법률",
    "ministry_name": "기획재정부",
    "enforcement_date": "2024-01-01",
    "jo_title": "목적",
    "jo_content": "이 법은 ...",
    "content_hash": "sha256-hex",
    "has_appendix": false,
    "references": []
  }
]

API OC 키 발급

법제처 오픈API 서비스 에서 이메일 주소를 OC 값으로 사용합니다.

파라미터

파라미터 타입 기본값 설명
law_names list[str] 필수 수집할 법령명 목록
output_dir str | Path "." JSON 저장 디렉토리
oc str | None None 법제처 API OC 키 (없으면 LAW_OC 환경변수)
concurrency int 3 동시 HTTP 요청 수

동작 원리

  1. MST 조회: lawSearch API로 법령명 → 법령ID(MST) 변환
  2. XML 수집: lawService API로 조문 전체 XML 다운로드
  3. 파싱: 조문 단위로 평탄화 (조문 1개 = 레코드 1개, 항/호/목은 본문에 병합)
  4. 해싱: 조문제목 + 조문내용 + 시행일자 기반 SHA-256 해시 계산
  5. 참조 추출: 조문 내 타법 참조(낫표), 내부 조문 참조 그래프 추출
  6. 저장: Silver 레이어 포맷 JSON 파일로 저장

Metadata

Release files for kr-law-extractor 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kr-law-extractor 0.1.0
File Size Uploaded Provenance Actions
kr_law_extractor-0.1.0.tar.gz 25.3 kB Without provenance Details for kr_law_extractor-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kr-law-extractor 0.1.0
File Interpreter ABI Platform Actions
kr_law_extractor-0.1.0-py3-none-any.whl Python 3 none any Details for kr_law_extractor-0.1.0-py3-none-any.whl

Total release size: 35.6 kB

Release files / kr_law_extractor-0.1.0.tar.gz

Download URL kr_law_extractor-0.1.0.tar.gz
Size 25.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0be6231c2bf48ebbde61358e432e1d8875259bf19898d75382170b29253445ff
BLAKE2b-256 checksum
How to use checksums
2424148ef922ae33e3c2cff264dd19d67fbbed19c2401689b3ea2218bceafc23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / kr_law_extractor-0.1.0-py3-none-any.whl

Download URL kr_law_extractor-0.1.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e789dde3457e742b231cb0ad1c5e51c8eaee43ff2f26cf15669fb996d9eb8886
BLAKE2b-256 checksum
How to use checksums
b3e4e0a382b6e69f22ce51a88f19d2af92c91c68a65d3db1163c7d5c174b1c49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for kr-law-extractor 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page