Assignment5-ISS
Where the ISS at?
The API that I chose to highlight would be “Where the ISS at?” and you can access it through the following link without the need of an API key. https://api.wheretheiss.at/v1/satellites/25544
The numbers at the end of that API are what signify that this is the International Space Station. In this case, “25544” corresponds to the NORAD Catalog Number assigned to the International Space Station (ISS). NORAD, which stands for North American Aerospace Defense Command, maintains a catalog of all objects in Earth orbit, including satellites and space debris. Each object is assigned a unique NORAD Catalog Number for identification purposes.
When doing research, I found that the ISS is currently the only object in orbit that has a working API, however, the article that I read may be outdated.
What it does
What this does is give you information on where the International Space Station currently is.
Some examples of the information given include but are not limited to:
Latitude
Longitude
Altitude
Velocity
Uses
Because the API gives real time information about the ISS, it would be cool to visualize those coordinates on a map. Using some code in R, we are able to plot where the ISS is on the map in real time.
Another use that I think would be pretty cool would be an app notifying you when the ISS is above you. That way you could get a notification on your phone, look up, and get to see the ISS. Just looking up to see a glowing dot and knowing there are 8 astronauts up there seems pretty cool to me. To make this app you could use this API along with the Google Maps API for the visualization and there is also an API for the names of the astronauts currently on board.
Setup
Packages
To begin, we need to download the packages below
library(httr)
library(jsonlite)The httr package allows us to make HTTP requests which allows us to interact with APIs using functions such as GET.
The jsonlite package allows R to read the API, as an API give us info that usually comes in JSON format.
Endpoint
An endpoint for our API is needed to make a call for the ISS data.
ISS <- "https://api.wheretheiss.at/v1/satellites/25544"Demonstration
Now that we have our endpoint and our packages loaded in, I will make a call to the API and create a visual.
The Code
# Download leaflet to create the map visual
library(leaflet)
# Make GET request
response <- GET(ISS)
# Check if request was successful
if (http_status(response)$category == "Success") {
# Interpret JSON content
content <- content(response, as = "text")
iss_info <- fromJSON(content)
# Extract latitude and longitude
latitude <- iss_info$latitude
longitude <- iss_info$longitude
# Create a leaflet map
map <- leaflet() %>%
addTiles() %>%
setView(lng = longitude, lat = latitude, zoom = 3) %>%
addMarkers(lng = longitude, lat = latitude)
# Print the map
print(map)
} else {
print("Error in fetching data from the API.")
}The Result
Map
This screenshot of the map is what the code above will produce. Using the leaflet package, it allows us to create this leaflet map that gets updated anytime you run the code. The marking on the map indicates where the ISS is at the time of running the command.
ISS chart
The chart above is a screenshot of the chart that we saved into the global environment using the following code:
# Interpret JSON content
content <- content(response, as = "text")
iss_info <- fromJSON(content)It is all of the information that the API gives us and if we wanted to create any type of visual, this is where we would get the data from.