0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

航空機のAPIについてChatGPT先生に教えてもらう

Posted at

この記事は航空機や空港のAPIに関しての Advent Calendar 2024の13日目の記事です。

航空機のAPIがあることをこのAdvent Calendarで今知ったところです。
おもしろそうなので、ChatGPT先生と一緒に試してみます。

航空機や空港のAPIを知っているかChatGPT先生に聞いてみる。
スクリーンショット 2024-12-20 0.51.29.png
スクリーンショット 2024-12-20 0.51.44.png
スクリーンショット 2024-12-20 0.51.54.png
スクリーンショット 2024-12-20 0.52.03.png
スクリーンショット 2024-12-20 0.52.11.png
スクリーンショット 2024-12-20 0.52.24.png
スクリーンショット 2024-12-20 0.52.46.png
スクリーンショット 2024-12-20 0.52.53.png
スクリーンショット 2024-12-20 0.52.59.png
スクリーンショット 2024-12-20 0.53.07.png
スクリーンショット 2024-12-20 0.53.17.png
スクリーンショット 2024-12-20 0.53.25.png
スクリーンショット 2024-12-20 0.53.33.png
スクリーンショット 2024-12-20 0.53.40.png
スクリーンショット 2024-12-20 0.53.48.png
スクリーンショット 2024-12-20 0.53.54.png
スクリーンショット 2024-12-20 0.54.01.png
スクリーンショット 2024-12-20 0.54.09.png
スクリーンショット 2024-12-20 0.54.18.png
スクリーンショット 2024-12-20 0.54.27.png
スクリーンショット 2024-12-20 0.54.35.png
スクリーンショット 2024-12-20 0.54.41.png
スクリーンショット 2024-12-20 0.54.47.png
スクリーンショット 2024-12-20 0.54.54.png

sky.py
import requests

# OpenSky Network APIのエンドポイント
url = "https://opensky-network.org/api/states/all"

try:
    # APIにリクエストを送信
    response = requests.get(url)
    response.raise_for_status()  # HTTPエラーが発生した場合例外を投げる

    # JSONデータを取得
    data = response.json()

    # フライトデータのサンプル表示(上位5件)
    print("航空機データのサンプル:")
    for flight in data.get("states", [])[:5]:  # 最初の5件を表示
        print(f"コールサイン: {flight[1]} | 国籍: {flight[2]} | 緯度: {flight[6]} | 経度: {flight[5]}")

except requests.exceptions.RequestException as e:
    print(f"APIリクエスト中にエラーが発生しました: {e}")

実行結果

スクリーンショット 2024-12-20 0.56.02.png

おお。無料なのが、素晴らしい!。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?