1. Explain the service you intend to demonstrate and why someone would want to use it.

This NASA API “How Many People Are In Space Right Now” can return the number of people currently in space as well as the names and spacecrafts that those people are currently on.

2)Walkthrough the steps for setting up the API both in R and on the service’s website (if necessary.)

library(tidyverse) 
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── 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

Defining the API endpoint by assigning the copy & pasted endpoint given to us to a value(nasa endpoint).

nasa_endpoint <- "http://api.open-notify.org/astros.json"

There are normally some filters that can be used on the API data to help specify how the results will appear. Since this NASA data in particular is pretty small, since there aren’t a lot of people in space at the same time. I didn’t feel the need to filter any data, but its always an option if need be!

This is where you would put all of your filters, queries and specifications for your API. In my case, there is not a lot of data so I don’t feel the need to filter the data, but this is where it would all come together and be assigned to a value to make it a cohesive api.

nasa_api_GET <- 
  paste(nasa_endpoint)

This is where the final product comes together. This is where we extract the API call results into a data frame. This is where the API becomes usable in R.

nasa_data <- 
  nasa_api_GET %>% 
  eval() %>% 
  fromJSON() 

This is a quick example of what we can look at within the NASA API. I am looking at the second object within the NASA data, which actually shows us the name and spacecraft that the people currently in space are on!

nasa_data %>% 
  extract2(2)
##                 name craft
## 1    Jasmin Moghbeli   ISS
## 2   Andreas Mogensen   ISS
## 3   Satoshi Furukawa   ISS
## 4 Konstantin Borisov   ISS
## 5     Oleg Kononenko   ISS
## 6       Nikolai Chub   ISS
## 7       Loral O'Hara   ISS