Skip to main content

공공데이터포털 api 다운로드

Project description

dataportal


공공데이터포털 api를 이용하여 데이터를 다운로드 하기 위한 라이브러리입니다.
xml의 경우 OrderedDict 형태로 데이터를 불러오고 json의 경우 json 형태로 데이터를 불러옵니다.

Guide


사용법은 매우 간단합니다. (예시를 위해 기상청 일기도 api를 활용하였습니다.)

아래와 같이 response부분과 데이터 다운로드 부분을 분리하여 할수도 있고

url = 'http://apis.data.go.kr/1360000/WthrChartInfoService'
serviceKey = 'Test'
operation = 'getSurfaceChart'
params = {'code' : 12, 'time' : '20211118'}

dataportal = DataportalApi(url, serviceKey, operation, params)
dataportal.get_request_query()
api_out = dataportal.parse_response()
print(api_out.head())

아래와 같이 모든 과정을 한번에 처리할 수도 있습니다.

url = 'http://apis.data.go.kr/1360000/WthrChartInfoService'
serviceKey = 'Test'
operation = 'getSurfaceChart'
params = {'code' : 12, 'time' : '20211118'}

dataportal = DataportalApi(url, serviceKey, operation, params)
api_out = dataportal.load(verbose=False)
print(api_out.head())

Requires


  • xmltodict>=0.12.0
  • requests>=2.25.1
  • urllib3>=1.26.4

Project details


Download files

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

Source Distribution

dataportal-0.0.6.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

dataportal-0.0.6-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

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