今回は、Postmanで天気APIを使って現在の東京の天気情報を取得してみたいと思います。
まずはPostmanにて+ボタンから「新しいリクエスト作成」を行います。次に画面中央にURLを張り付ける箇所があるのでAPIから天気情報を取得するためのURLを貼り付けます。
https://api.openweathermap.org/data/2.5/weather?q=Tokyo&appid=YOUR_API_KEY&units=metric&lang=ja
Code language: JavaScript (javascript)
YOUR_API_KEYの部分は自分の天気APIKEYを入力します。
今回は情報取得なので左の欄をGETにしておきます。
これで送信すると以下のような文がJson形式でかえってきます。
{
"coord": {
"lon": 139.6917,
"lat": 35.6895
},
"weather": [
{
"id": 803,
"main": "Clouds",
"description": "broken clouds",
"icon": "04d"
}
],
"base": "stations",
"main": {
"temp": 31.13,
"feels_like": 35.38,
"temp_min": 30.79,
"temp_max": 32.59,
"pressure": 1016,
"humidity": 61,
"sea_level": 1016,
"grnd_level": 1015
},
"visibility": 10000,
"wind": {
"speed": 8.23,
"deg": 180
},
"clouds": {
"all": 75
},
"dt": 1752807938,
"sys": {
"type": 2,
"id": 268395,
"country": "JP",
"sunrise": 1752781106,
"sunset": 1752832562
},
"timezone": 32400,
"id": 1850144,
"name": "Tokyo",
"cod": 200
}
Code language: JSON / JSON with Comments (json)
どれが何を表しているのかをまとめていきます。
天気概要
“main”: “Clouds”,
“description”: “broken clouds”,
“icon”: “04d”
天気種別: 雲(Clouds)
詳細: 所々曇り(broken clouds)
アイコンコード: 04d
(昼の雲アイコン)
気温・湿度
“temp”: 31.13, ← 気温(℃)
“feels_like”: 35.38, ← 体感温度(℃)
“temp_min”: 30.79, ← 最低気温(℃)
“temp_max”: 32.59, ← 最高気温(℃)
“humidity”: 61 ← 湿度(%)
“pressure”: 1016 ← 気圧(hPa)
風
“speed”: 8.23, ← 風速(m/s)
“deg”: 180 ← 風向(南風)
雲の量
“clouds”: { “all”: 75 } → 雲が空全体の75%を覆っている
日の出、日の入り
“sunrise”: 1752781106
“sunset”: 1752832562 → これはUNIXタイムスタンプなので、変換が必要です。
ちなみに変換ツールで日の出を変換すると2025/07/18 04:38:26と出ました。
まとめ
Postmanを使うことで簡単に多くの情報を取得することが出来ました。