NASA APIを使って簡単なアプリの作成過程を記録として残していく。
最初は使用するAPIの説明と画面イメージを説明。実装は②から。(順次投稿予定)
①NASA APIを使って簡単なアプリ作ってみた① ←こちらの記事
②NASA APIを使って簡単なアプリ作ってみた②
③NASA APIを使って簡単なアプリ作ってみた③
④NASA APIを使って簡単なアプリ作ってみた④ (9月中に公開予定)
NASA APIについて
無料で宇宙に関する情報を取得できるNASA APIを使用してアプリを作成する。
今回は以下の2つのAPIを使用する。
・APOD:Astronomy Picture of the Day(今日の天文学の写真)
毎日違う宇宙の情報や写真が公開される。このWebサイトはジャスティン・ビーバーのビデオのぐらいの人気があるらしい。
- method
- GET
- Request
- Query Parameters
パラメータ 型 デフォルト値 説明 date YYYY-MM-DD 今日 取得する APOD画像の日付 start_date YYYY-MM-DD なし 日付を範囲指定する場合の開始日。dateと一緒に使用することはできない。 end_date YYYY-MM-DD 今日 日付を範囲指定する場合の終了日。start_dateと一緒に使用する。 count int なし 指定した個数分ランダムに画像が返される。dateとstart_dateとend_dateと一緒に使用することはできない。 thumbs bool False 動画のサムネイルのURL。APODが動画でない場合は無視される。 api_key string DEMO_KEY APIを使用するためのkey - Responce
{ "copyright": "Fred Espenak", "date": "2025-06-12", "explanation": "On April 20, 2023 the shadow of a New Moon raced across planet Earth's southern hemisphere. When viewed along a narrow path that mostly avoided landfall, the Moon in silhouette created a hybrid solar eclipse. Hybrid eclipses are rare and can be seen as a total eclipse or an annular \"ring of fire\" eclipse depending on the observer's position. Viewers of this much anticipated hybrid event were able to witness a total solar eclipse while anchored in the Indian Ocean near the centerline of the eclipse track off the coast of western Australia. This ship-borne image from renowned eclipse chaser Fred Espenak captured the eclipsed Sun's magnificent outer atmosphere, or solar corona, streaming into space. The composite of 11 exposures ranging from 1/2000 to 1/2 second, taken during the 62 seconds of totality, records an extended range of brightness to follow alluring details of the corona not quite visible to the eye. Fred Espenak (1953-2025)", "hdurl": "https://apod.nasa.gov/apod/image/2506/TSE2023-Comp48-2a.jpg", "media_type": "image", "service_version": "v1", "title": "Solar Eclipse", "url": "https://apod.nasa.gov/apod/image/2506/TSE2023-Comp48-2a1024.jpg" }
・InSight: Mars Weather Service API
火星の気象情報を取得することができる。NASAの火星着陸船「インサイト」が温度、風、気圧などの気象を連続的に測定したデータ。
- method
- GET
- Request
- Query Parameters
パラメータ 型 デフォルト値 説明 version float 1.0 APIのバージョン feedtype string json レスポンスの形式は現在のデフォルトがJSONであり、JSONのみが機能する。 end_date string DEMO_KEY APIを使用するためのkey - Responce (一部抜粋)
{ "259": { "AT": { "av": -71.233, "ct": 326642, "mn": -101.024, "mx": -27.149 }, // 気温 "HWS": { "av": 4.35, "ct": 154146, "mn": 0.156, "mx": 17.617 }, // 水平風速 "PRE": { "av": 761.006, "ct": 163012, "mn": 742.1498, "mx": 780.3891 }, // 気圧 "WD": { // 風向き "most_common": { "compass_degrees": 202.5, "compass_point": "SSW", "compass_right": -0.382683432365,"compass_up": -0.923879532511, "ct": 28551 }, "8": { "compass_degrees": 180.0, "compass_point": "S", "compass_right": 0.0, "compass_up": -1.0, "ct": 17699 }, "9": { "compass_degrees": 202.5, "compass_point": "SSW", "compass_right":-0.382683432365,"compass_up": -0.923879532511, "ct": 28551 }, "10": { "compass_degrees": 225.0, "compass_point": "SW", "compass_right": -0.707106781187,"compass_up": -0.707106781187, "ct": 27124 } }, "First_UTC": "2019-08-19T08:03:59Z", "Last_UTC": "2019-08-20T08:43:34Z", "Season": "winter” }, "260": { "AT": { "av": -75.95, "ct": 300789, "mn": -101.715, "mx": -28.634 }, "PRE": { "av": 762.462, "ct": 149206, "mn": 741.1254, "mx": 777.796 }, "WD": { "most_common": null } "First_UTC": "2019-08-20T08:43:34Z", "Last_UTC": "2019-08-21T09:23:09Z", "Season": "winter" }, "261": {...}, "262": {...}, "263": {...}, "264": {...}, "265": {...}, ・ ・ ・ }
数字のキーはSolというもので火星の一日を表す単位。
Sol 100(ソル100日目):「その探査機が火星に着陸してから100火星日が経過した」という意味。
NASA APIについては公式サイトを参考にしてください。
画面イメージ
APIで取得したデータを表示する画面と各画面に遷移するためのトップ画面を作成する。

最後に
次から各画面の実装について書いていく。
最初はAndroidのアプリを作成する。(Android完成後、iOSも作成する予定。)