LoginSignup
24
22

More than 3 years have passed since last update.

地域経済分析システム(RESAS:リーサス) API を使ってみる(1)

Last updated at Posted at 2016-11-02

地域経済分析システム(RESAS:リーサス) API とは

地域経済分析システム(RESAS:リーサス)のAPIがつい最近(2016年11月1日)公開されました。

API を使うには、

  • API-KEY を取得 上記URLから取得してください。
  • API-KEY を設定して、ほしいデータをGETします。

(例) python でのコード例です。都道府県のコード一覧をとってきます。api-key の部分は入れ替えてください。json で戻ってきます。python は、jupyter notebook で簡単につかえますので、windows の方も試してみましょう。

import requests,json
def get_resas(key,url):
    x = json.loads(requests.get('https://opendata.resas-portal.go.jp/' + url, 
                 headers={'X-API-KEY':key}).text)
    return(x['message'],x['result'])
get_resas('ここにAPI-KEY','api/v1-rc.1/prefectures')

戻り値は、こんな感じ

(None,
 [{'prefCode': 1, 'prefName': '北海道'},
  {'prefCode': 2, 'prefName': '青森県'},
  {'prefCode': 3, 'prefName': '岩手県'},
  {'prefCode': 4, 'prefName': '宮城県'},
24
22
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
22