Skip to main content

kr-data-portal-client

Production-ready, async-first Python client for the KR Public Data Portal (공공데이터포털).

Features

  • Async First: Built on httpx for high-performance asynchronous operations.
  • Spec-Driven: Generated from YAML specifications to ensure accuracy.
  • Robust Models: Uses Pydantic for strict response validation and easy data access.
  • Rate Limiting: Built-in async rate limiter to comply with portal usage policies.
  • Google-Style Docstrings: Full IDE support with detailed parameter descriptions and data update policies.

Installation

pip install kr-data-portal-client

[!IMPORTANT] Recommended Version: 0.1.8+
Previous versions (0.1.7 and below) are considered deprecated (yanked) due to critical API encoding and consistency issues. Version 0.1.8 introduces a custom URL construction logic to properly handle Service Key encoding requirements of the KR Public Data Portal.

Quick Start

import asyncio
from kr_data_portal.financial_services import FinancialClient
from kr_data_portal.models.financial_services import StockPriceInfoItem

async def main():
    service_key = "YOUR_SERVICE_KEY"
    
    async with FinancialClient(service_key=service_key) as client:
        # Fetch stock price info
        response = await client.getStockPriceInfo(itmsNm="삼성전자")
        
        # Access validated items
        items = response.items(StockPriceInfoItem)
        for item in items:
            print(f"{item.itmsNm}: {item.clpr} KRW")

if __name__ == "__main__":
    asyncio.run(main())

Development

Project Structure

  • src/kr_data_portal/: Core package.
  • specs/: API specification files (YAML).
  • scripts/: Code generation scripts.
  • tests/: Unit tests.

Code Generation

To regenerate the client from specifications:

python scripts/generate_client.py

Running Tests

uv run pytest

Contributing

Please see CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests. We use Conventional Commits for automated release management.

License

MIT

Metadata

Release files for kr-data-portal-client 0.1.9

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-data-portal-client 0.1.9
File Size Uploaded
kr_data_portal_client-0.1.9.tar.gz 81.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kr-data-portal-client 0.1.9
File Interpreter ABI Platform
kr_data_portal_client-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 88.9 kB

Release files / kr_data_portal_client-0.1.9.tar.gz

Download URL kr_data_portal_client-0.1.9.tar.gz
Size 81.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a4f5866939f4b247f389944ea87f2da426e4cedcc3c6a7cee76876b360933a5e
BLAKE2b-256 checksum
How to use checksums
f6ae9d7f643412eea3b1ed39558619638b6155368e585b9c66f16f4de09182b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / kr_data_portal_client-0.1.9-py3-none-any.whl

Download URL kr_data_portal_client-0.1.9-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c587baa6e954a35112a46a26aa4dd523088545185cd61186ee8456189207fac
BLAKE2b-256 checksum
How to use checksums
7369a3f9de37cf2da06d6100a1ae36de873b77644efa0d977d8345421734eec8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

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