Capture-and-replay HomeTax HTTP client designed for AI agents and developers (unofficial).
Project description
hometax-agent-client
Capture-and-replay HomeTax (hometax.go.kr) HTTP client for Python — designed
to be called from AI agents and small developer scripts.
The library wraps HomeTax's wqAction.do request/response convention
(JSON body + HMAC suffix signed by nts_encrypt) so callers can issue typed
inquiries without driving a browser. Browser-based session bootstrap is
optional and isolated to the [bootstrap] extras.
⚠️ Status: alpha. Public API is stabilizing; expect breaking changes until 0.2. Contributions and bug reports welcome.
본 프로젝트는 국세청 / 홈택스 / NTS 와 무관한 비공식(unofficial) 라이브러리입니다. 국세청의 인가 / 후원 / 검수를 받지 않았으며, 홈택스의 변경에 대한 어떠한 호환 보장도 제공하지 않습니다.
주요 특징
- HTTP-only 데이터 평면. 라이브러리 본체는
curl_cffi위에서 동작하며 Playwright 같은 브라우저 의존을 코어에서 제거했다. 인증 부트스트랩이 필요할 때만[bootstrap]extras 를 설치한다. - 두 층 API.
client.<service>.<method>()로 typed 결과를 받거나,client.wq_action(...)raw 통로로 직접 호출할 수 있다. 홈택스가 응답 shape 을 바꿔도 raw 통로로 즉시 우회 가능. - Drift-tolerant 모델. 모든 dataclass 가
raw를 들고 있어, 라이브러리가 알지 못하는 새 필드도 보존된다. 응답 핵심 필드가 사라진 경우는ResponseSchemaDriftError로 raise. - Facts as data. 액션 ID, 화면 ID 같은 식별자는
hometax_client/facts/current.toml에 데이터로 분리해 두어, 코드 변경 없이 catalog 만 갱신하면 된다. - 타입화된 에러 계층. 모든 라이브러리 예외가
HometaxError를 상속.SessionExpiredError,LoginRequiredError,ProtectedLoginError,AuthGradeInsufficientError등으로 세분화되어 agent 가 string 매칭 없이 분기 가능. - 다중 세션 관리.
SessionStore한 디렉토리에 여러 고객 세션을<client_id>.json으로 보관. list / open / health / find_by_tin 등 일관 API. 세무사 사무실 다중 클라이언트 워크플로용 (docs/sessions.md). - Service-health 도구.
python -m hometax_client.health로 NTS_KEYS drift 즉시 검출,--refresh로 자동 cache 갱신.
English summary
hometax-agent-client is a small Python library that talks directly to
HomeTax (Korea's national tax portal) over HTTPS. It is built for AI agents
and developers who want to obtain HomeTax data programmatically without
running a real browser. Authentication can be done via:
- OACX (Kakao/Naver simple-auth): user-driven, no automation possible for the phone-tap step.
- ID/PW + RRN: HTTP-only path. May be blocked by HomeTax's 2026-05
protection script — in that case, use the
[bootstrap]extras to seed cookies once with a real browser, then switch to the cookie-based client.
Inquiries are exposed as client.<service>.<method>() calls returning typed
dataclasses (or raw dicts via the escape-hatch path).
See docs/architecture.md for the design rationale and docs/extending.md
for adding a new tax service.
설치
# 라이브러리만 (HTTP-only 코어)
uv add hometax-agent-client
# 부트스트랩 도구 함께 (브라우저로 한 번만 cookies 캡처)
uv add "hometax-agent-client[bootstrap]"
Python 3.12 이상.
빠른 시작
1. 쿠키 기반 (권장)
브라우저 캡처 또는 부트스트랩 도구로 받은 cookies.json 으로 시작한다.
from hometax_client import HometaxClient
client = HometaxClient.from_cookies(
cookies_path="captures/2026-05-01/cookies.json",
user_id="your_id",
tin="1234567890",
)
info = client.session_info()
print(info.user_name, info.tin)
# 지급명세서 조회 (귀속연도 2024)
statements = client.inquiries.income_statements(attr_year=2024)
for statement in statements:
print(statement.material_kind_name, statement.payer_name)
# 종합소득세 신고도움 — 자료구분별 소득내역
income = client.income_tax.income_details(attr_year=2024)
2. ID/PW 직접 로그인 (위험: 보호 스크립트 변경에 영향)
from hometax_client import HometaxClient
from hometax_client.auth import IdPwAuth
auth = IdPwAuth(
user_id="your_id",
password="your_password",
rrn="900101-1",
)
client = HometaxClient.login(auth=auth)
pubcLogin.do 가 HTTP 400 또는 partial 세션을 반환할 경우
ProtectedLoginError 가 raise 된다. 이때는 부트스트랩 경로 또는 OACX 인증을
사용해야 한다.
3. Raw 통로 (escape hatch)
홈택스가 새 메뉴를 추가했거나 라이브러리가 아직 따라가지 못한 응답이라면
직접 wq_action() 으로 호출 가능.
data = client.wq_action(
action_id="ATERNAxxxR01",
screen_id="UTERNAxxx",
host="teht",
body={"attrYr": "2024"},
)
4. 다중 세션 관리 (SessionStore)
여러 고객 세션을 한 디렉토리에서 일관 API 로 다룬다. 자세한 내용은
docs/sessions.md.
from hometax_client import SessionStore
store = SessionStore() # 기본 captures/sessions/
store.save(client, client_id="kim_chulsoo", label="김철수", auth_method="idpw")
for entry in store.list():
print(entry.client_id, entry.label, entry.tin, entry.auth_method)
client = store.open("kim_chulsoo") # last_used_at 자동 갱신
health = store.health("kim_chulsoo") # 'recent' / 'stale' / 'missing'
책임 / 이용 범위
- 본인 명의 자료 자동 조회 또는 적법한 위임을 받은 사용자 자료 조회만 의도한다. 동의 / 위임 없이 제3자 자료를 조회하면 안 된다.
- 세무대리 시: 적법한 위임 절차 (수임동의 등) 가 선행되어야 한다. 본 라이브러리 자체는 위임 검증 / 권한 확인을 하지 않는다 — 적법성은 사용자 책임.
- 홈택스 이용약관, 정보통신망법, 개인정보보호법, 그 외 관련 법규 준수 여부는 사용자가 자체 판단한다. 본 라이브러리 사용에 따른 모든 법적 / 운영 위험은 사용자에게 있다.
- raw 통로 (
wq_action) 로 임의 액션 호출이 기술적으로 가능하다 — 호출 결과 / 영향 / 적법성은 사용자 책임.
보안 / 자격증명
- 외부 통신 없음. 라이브러리는
hometax.go.kr서브도메인 + NetFunnel 큐 (apct.hometax.go.kr) 외 어떤 외부 호스트와도 통신하지 않는다. 텔레메트리 / 로깅 서버 / 분석 백엔드 일체 없음. - 자격증명은 사용자 머신에만. ID / 비밀번호 / 주민번호 / 세션 쿠키는 메모리 또는 사용자가 지정한 파일 (cache_path / SessionStore) 에만 저장. 네트워크로 나가는 곳은 홈택스 자체뿐.
- 세션 캐시 권한.
save_session/SessionStore.save가 만드는 파일은0o600(사용자만 read/write) 권한으로 저장된다. .gitignore처리.captures/,out/,*.session.json,.env모두.gitignore에 포함되어 있다. 임의로 제외하면 자격증명 / 세션이 git history 에 남을 수 있음.- 보안 취약점 발견 시
SECURITY.md절차로 보고.
예제
examples/basic_inquiry.py— 쿠키 기반 단건 조회examples/auth_kakao.py— 카카오 OACX 인증 → 세션 캐시examples/auth_idpw.py— ID/PW 직접 로그인examples/income_tax_inquiry.py— 종합소득세 신고도움 서비스 호출examples/recon_login.py— Playwright 로 브라우저 로그인 통과 후 cookies / HAR 캡처 (docs/recon.md)examples/web-sample/— 라이브러리를 작은 웹 UI 에 연결한 단순 데모 (단건 조회 한 화면)
프로젝트 문서
docs/architecture.md— 두 층 API, 의존성 정책, 라이브러리 vs 워크플로 경계docs/conventions.md— 모듈/클래스/메서드/예외 네이밍 규약docs/extending.md— 새 세목(법인세/원천세/양도세 등) 추가 패턴docs/compatibility.md— 홈택스 변경에 대한 내성, 안정성 계약, 응답 drift 처리docs/hometax-facts.md— 캡처로 검증된 사실의 단일 출처docs/cert-login-reference.md— NPKI 공인인증서 로그인 흐름 분석 (옛hometax-scraper코드 기반, 미구현 영역의 출발점)docs/recon.md— 브라우저 recon / cookies 캡처 도구 사용법docs/sessions.md— 다중 세션 관리 (SessionStore)
기여 / 보안
- 기여 절차:
CONTRIBUTING.md - 보안 취약점 보고:
SECURITY.md
라이선스
MIT — LICENSE 참조. 본 라이브러리는 무보증으로 제공되며 (AS IS),
홈택스 / NTS 와 무관한 비공식 프로젝트임을 다시 한 번 명시합니다.
Project details
Release history Release notifications | RSS feed
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 hometax_agent_client-0.1.0a1.tar.gz.
File metadata
- Download URL: hometax_agent_client-0.1.0a1.tar.gz
- Upload date:
- Size: 138.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ab223138d3a6e7ef79016debb6f6a1ba1081924604e04b2db7b33059ca01d33
|
|
| MD5 |
c29a1c4c7a3d8ebd2cf40db5fdff793c
|
|
| BLAKE2b-256 |
a028002de8df0d2029ab8206a4501c3de44d554b9647cc7dd8657a7da57d77ad
|
Provenance
The following attestation bundles were made for hometax_agent_client-0.1.0a1.tar.gz:
Publisher:
release.yml on myjung/hometax-agent-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hometax_agent_client-0.1.0a1.tar.gz -
Subject digest:
2ab223138d3a6e7ef79016debb6f6a1ba1081924604e04b2db7b33059ca01d33 - Sigstore transparency entry: 1496415901
- Sigstore integration time:
-
Permalink:
myjung/hometax-agent-client@c9ec56c7ffe8a64b48481031f892e78e65a3602f -
Branch / Tag:
refs/tags/v0.1.0a1 - Owner: https://github.com/myjung
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c9ec56c7ffe8a64b48481031f892e78e65a3602f -
Trigger Event:
push
-
Statement type:
File details
Details for the file hometax_agent_client-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: hometax_agent_client-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 67.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf209044810e43873b008558c52c5f6718aa18f0c0ef5bfd965302ccea169587
|
|
| MD5 |
53b2a9db5709f568e02e5021f7d95939
|
|
| BLAKE2b-256 |
46f488b760dc377d1051d4803e056acca3ab74eb8decbf690894fe25ad00b074
|
Provenance
The following attestation bundles were made for hometax_agent_client-0.1.0a1-py3-none-any.whl:
Publisher:
release.yml on myjung/hometax-agent-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hometax_agent_client-0.1.0a1-py3-none-any.whl -
Subject digest:
cf209044810e43873b008558c52c5f6718aa18f0c0ef5bfd965302ccea169587 - Sigstore transparency entry: 1496416029
- Sigstore integration time:
-
Permalink:
myjung/hometax-agent-client@c9ec56c7ffe8a64b48481031f892e78e65a3602f -
Branch / Tag:
refs/tags/v0.1.0a1 - Owner: https://github.com/myjung
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c9ec56c7ffe8a64b48481031f892e78e65a3602f -
Trigger Event:
push
-
Statement type: