한국은행 경제통계시스템(ECOS) REST API Python 클라이언트
Project description
ecos-api
한국은행 경제통계시스템(ECOS) REST API Python 클라이언트
설치
pip install ecos-api
사용법
ECOS Open API 인증키를 발급받아 사용합니다.
기본 사용
from ecos import EcosClient, Cycle
client = EcosClient("YOUR_API_KEY")
# 통계 데이터 조회 (GDP, 연간, 2020~2023)
rows = client.search("200Y001", Cycle.ANNUAL, "2020", "2023")
for row in rows:
print(row.time, row.item_name1, row.data_value)
# 주요통계 100선
stats = client.get_key_statistics()
for s in stats:
print(s.keystat_name, s.data_value, s.unit_name)
# 통계표 목록 조회
tables = client.list_tables()
# 통계표 항목 조회
items = client.list_items("200Y001")
# 통계표 메타데이터 조회
meta = client.get_meta("200Y001")
# 통계 용어 검색
words = client.search_word("GDP")
비동기 사용
import asyncio
from ecos import EcosClient, Cycle
async def main():
async with EcosClient("YOUR_API_KEY") as client:
rows = await client.search_async("200Y001", Cycle.ANNUAL, "2020", "2023")
for row in rows:
print(row.time, row.data_value)
asyncio.run(main())
Context Manager
with EcosClient("YOUR_API_KEY") as client:
rows = client.search("731Y001", Cycle.DAILY, "20240101", "20240131")
API 메서드
| 메서드 | 비동기 | 설명 |
|---|---|---|
search() |
search_async() |
통계 데이터 조회 |
list_tables() |
list_tables_async() |
통계표 목록 조회 |
list_items() |
list_items_async() |
통계 항목 목록 조회 |
get_meta() |
get_meta_async() |
통계표 메타데이터 조회 |
get_key_statistics() |
get_key_statistics_async() |
주요통계 100선 |
search_word() |
search_word_async() |
통계 용어 검색 |
주기 코드 (Cycle)
| 값 | 설명 | 날짜 형식 |
|---|---|---|
Cycle.ANNUAL |
연간 | 2020 |
Cycle.QUARTER |
분기 | 20201 |
Cycle.MONTHLY |
월간 | 202001 |
Cycle.SEMI_ANNUAL |
반기 | 20201 |
Cycle.DAILY |
일별 | 20200101 |
개발
pip install -e ".[dev]"
pytest
ruff check .
mypy src/
라이선스
MIT
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
ecos_api-0.1.0.tar.gz
(6.8 kB
view details)
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 ecos_api-0.1.0.tar.gz.
File metadata
- Download URL: ecos_api-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4166ad4a135ac98c52406e8e22bb62b6f687dcfee011e158f2e38e937fc4047
|
|
| MD5 |
7532b2341441d2274a8d1971154375ea
|
|
| BLAKE2b-256 |
fe6c2c59422196bba2c7cda8e14feaa7ec34d96cf125fa91b5a23322b86e91f5
|
File details
Details for the file ecos_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ecos_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d34d318dfbf6c699878d4103f691c66024fc4f7830f5d010cd3363b03c946de
|
|
| MD5 |
048ee4438b841288a012c291630dde2e
|
|
| BLAKE2b-256 |
5e1866ebfc89e2ffdb04c60d8ce6ca26157db79eb8593a46bed1e4562d808f1d
|