LoginSignup
0
0

学校コード検索APIを叩く

Posted at
import requests
def call_api():
    url = "https://api.edu-data.jp/api/v1/school"  # ここにAPIのエンドポイントを入力します
    headers = {"Authorization": "Bearer ここにトークンを入力"}  # 必要に応じてヘッダーを設定します

    try:
        response = requests.get(url, headers=headers)

        # ステータスコードが200 OKの場合
        if response.status_code == 200:
            # レスポンスから必要なデータを取得します
            data = response.json()
            return data
        else:
            print("API呼び出しに失敗しました。ステータスコード:", response.status_code)
            return None
    except Exception as e:
        print("エラーが発生しました:", e)
        return None

api_data = call_api()
print("APIからのデータ:", api_data)

0
0
0

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
0
0