APIs
Displaying Data From an API
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
// RapidAPI header https://rapidapi.com/dariuxmx/api/formula-1-standings/
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://formula-1-standings.p.rapidapi.com/races"))
.header("X-RapidAPI-Key", "80e73128e0mshda8c95123266391p176951jsnbc06ff234f92")
.header("X-RapidAPI-Host", "formula-1-standings.p.rapidapi.com")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
// RapidAPI request and response
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
// RapidAPI Body
System.out.println(response.body());