Skip to main content

parsing a bank of korea api

Project description

boklib

usage

from boklib import bok

api_key = 'example' # get an api key in this site: https://ecos.bok.or.kr/jsp/openapi/OpenApiController.jsp?t=main
lang = '' # 'kr'or 'en'
state_code = '' # get a state_code in table_list or get a state_code in item_list
cycle = '' # get a cycle in item_list
start_date = '' # get a start_date in item_list
end_date = '' # get a end_date in item_list
item_code = '' # get a item_code in item_list

bok = bok(api_key, lang)
result_key_list = bok.key_List()
result_table_list = bok.table_list()
result_item_list = bok.item_list(stat_code)
result_search = bok.search(stat_code, cycle, start_date, end_date, item_code)
result_meta = bok.meta(meta_search_word) # maybe korean language only - site: https://ecos.bok.or.kr/jsp/use/metadata/MetaData.jsp
result_word = bok.word(search_word) # maybe korean language only - site: https://ecos.bok.or.kr/jsp/use/metaword/MetaDataWordList.jsp

for result in result_key_list['row']:
  class_name =  result['CLASS_NAME']
  keystat_name = result['KEYSTAT_NAME']
  data_value = result['DATA_VALUE']
  cycle = result['CYCLE']
  unit_name = result['UNIT_NAME']
  print('class_name = %s, keystat_name = %s, data_value = %s, cycle = %s, unit_name = %s' % (class_name, keystat_name, data_value, cycle, unit_name))

#
# --- result example ---
# {'list_total_count': {}, 'row' : [] }
#
# print result_key_list
# {'list_total_count' : 1, 'row' : [{'CLASS_NAME' : '', 'KEYSTAT_NAME' : '', 'DATA_VALUE' : '', 'CYCLE' : '', 'UNIT_NAME' : ''}]}
#
# print result_table_list
# {'list_total_count': 1, 'row' : [{'P_STAT_CODE' : '', 'STAT_CODE' : '', 'STAT_NAME' : '', 'CYCLE' : '', 'SRCH_YN' : '', 'ORG_NAME' : ''}] }
#
# print result_item_list
# {'list_total_count' : 1, 'row' : [{'STAT_CODE' : '', 'STAT_NAME' : '', 'GRP_CODE' : '', 'GRP_NAME' : '', 'P_ITEM_CODE' : '', 'ITEM_CODE' : '', 'ITEM_NAME' : '', 'CYCLE' : '', 'START_TIME' : '', 'END_TIME' : '', 'DATA_CNT' : ''}]}
# print result_search
# {'list_total_count' : 1, 'row' : [{'STAT_CODE' : '', 'STAT_NAME' : '', 'ITEM_CODE1' : '', 'ITEM_CODE2' : '', 'ITEM_CODE3' : '', 'UNIT_NAME' : '', 'TIME' : '', 'DATA_VALUE' : ''}]}
#
# print result_meta
# {'list_total_count': 1, 'row' : [{'LVL' : '', 'P_CONT_CODE' : '', 'CONT_CODE' : '', 'CONT_NAME' : '', 'META_DATA' : ''}] }
#
# print result_word
# {'list_total_count': 1, 'row' : [{'WORD' : '', 'CONTENT' : ''}] }
#

Project details


Release history Release notifications | RSS feed

This version

1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boklib-1.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

boklib-1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file boklib-1.1.tar.gz.

File metadata

  • Download URL: boklib-1.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for boklib-1.1.tar.gz
Algorithm Hash digest
SHA256 3b411aeb5040210fba1104783e9384c2c69a259992c63fd680fa824309d561ec
MD5 78060d4ef85c6edc8658570607d3fc38
BLAKE2b-256 c98d7b8bff539e22312ef0044af03f3988867b500f9be0f5dbc4bee492630b06

See more details on using hashes here.

File details

Details for the file boklib-1.1-py3-none-any.whl.

File metadata

  • Download URL: boklib-1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for boklib-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2342e3f9e91f75b811fd80a5fb4557d5eae0f6dd43f4532617e9fa37f54d88e
MD5 3cc40016cabfacf2a61e7dd398322bdb
BLAKE2b-256 6acfdf1ad37cca8050e4b274059054d52ff942ac0e6076eb9d055b86a4faf3ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page