Google Books
public class main {
public static void main(String[] args) throws IOException, InterruptedException {
Scanner input = new Scanner(System.in);
var search = input.nextLine();
String query = URLEncoder.encode(search, StandardCharsets.UTF_8);
String edress = "https://www.googleapis.com/books/v1/volumes?q=" +query+ "&key=AIzaSyDxv7ZaossM1e6I2rRqPct4jwJS5scopQo";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(edress))
.build();
HttpResponse<String> response = client
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Coin Gecko
public class main2 {
public static void main(String[] args) throws IOException, InterruptedException {
Scanner input = new Scanner(System.in);
System.out.println("Digite ó nome de uma criptomoeda que deseja ver a cotação atual: ");
var search = input.nextLine();
String address = "https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd&ids="+search+"&x_cg_demo_api_key=CG-22R3nQHK2Qv7fEKmcnw6rcDt";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(address))
.build();
HttpResponse<String> response = client
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
ThemeaLDB
public class main3 {
public static void main(String[] args) throws IOException, InterruptedException {
Scanner input = new Scanner(System.in);
System.out.println("Digite o nome de um prato: ");
var search = input.nextLine();
String address = "www.themealdb.com/api/json/v1/1/search.php?s=" +search;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(address))
.build();
HttpResponse<String> response = client
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}