11/05 workshop 資料分析實戰步驟:
track: api ingestion / environment: antigravity / theme: dose

手把手動態錄影:取得日本政府 e-Stat 統計 API 金鑰

完整還原日本總務省統計局官方介面。解析核心避坑參數 http://test.localhost,動態演示從登入、發行 40 碼專屬金鑰到以 Python 程式獲取 47 都道府縣面板數據的全流程。

前往 e-Stat 官方首頁 ↗ 返回分析師工作流 ↗
e-stat sandbox
SECURE https://www.e-stat.go.jp/en/mypage/view/api
Contact us Japanese workshop-student@antigravity.dev My page Logout
Browse Statistics Visualisations and Tools Resources Links
Top Page / Display My page
Display My page
Get application ID
1
*name
*URL
* http://localhost and private IP address cannot be registered.
Overview
appId
STEP 1 / 5
登入並進入 My Page (個人中心)
登入後點擊右上角的「My page」,進入會員管理介面。
00:03s
00:00 / 00:24
1. 登入 2. 進入API 3. 避坑填寫 4. 發行Key 5. 程式串接

API 申請實體步驟速查與避坑說明

step-by-step checklist
step 01
登入並進入個人頁

前往 e-Stat 官網右上角點擊「My page」進入會員控制台。若原為日文版可切換為英文版。

step 02
鎖定 API 機能選單

點擊深藍色功能橫條中的 ▶ API function (application ID issuance) 進入金鑰管理表。

step 03 / 避坑核心
URL 嚴格規範

官方防禦機制嚴格禁止純 localhost!請務必填寫 http://test.localhost 即可直接通過驗證。

step 04 / 取得金鑰
點擊 Issue 發行

點擊右側 Issue 按鈕,系統立即生成 40 碼專屬金鑰(appId),後續呼叫 REST API 即可代入。

python: fetch_estat_api.py REST v3.0
import requests

app_id = "YOUR_40_CHAR_APP_ID"
url = "https://api.e-stat.go.jp/rest/3.0/app/json/getStatsData"
params = {
    "appId": app_id,
    "statsDataId": "0000010101", # SSDSE-A 47都道府縣社會人口大表
    "metaGetFlg": "Y"
}
response = requests.get(url, params=params)
data = response.json()
print(f"獲取成功,共載入 {len(data['GET_STATS_DATA']['STATISTICAL_DATA']['DATA_INF']['VALUE'])} 筆紀錄")
endpoint: api.e-stat.go.jp/rest/3.0/app / status: operational
返回分析師工作流 ↗