import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Scanner;
public class CoinGeckoApiExemplo {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Digite o nome da criptomoeda (por exemplo, bitcoin):");
String nomeCripto = scanner.nextLine();
String apiUrl = "https://api.coingecko.com/api/v3/simple/price?ids=" + nomeCripto + "&vs_currencies=usd";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(apiUrl))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Resposta da API: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}