This page demonstrates how to use the API of NASA’s data from Open Notify to find how many humans are in space right now and the current location of International Space Station (ISS). Those who are curious about space would want to use this to easily find information about this ISS and astronauts. Perhaps they could use the ISS location to map its path or calculate its distance from Earth. The creator of Open Notify created a lamp that lights up when the ISS flies over it.
Load packages
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.6
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.1 ✔ tibble 3.3.1
✔ lubridate 1.9.4 ✔ tidyr 1.3.2
✔ purrr 1.2.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(jsonlite)
Attaching package: 'jsonlite'
The following object is masked from 'package:purrr':
flatten
library(magrittr)
Attaching package: 'magrittr'
The following object is masked from 'package:purrr':
set_names
The following object is masked from 'package:tidyr':
extract
library(httr)
Setting up the API
The API is very easy to use. You either add “iss-now.json” to retrieve information about the international space station or “astros.json” to retrieve information about the astronauts in space right now, to the end of the base URL.