public class coinGeckoAPI {
public static void main(String[] args) throws IOException, InterruptedException {
Scanner leitura = new Scanner(System.in);
System.out.print("Digite uma cripto moeda para busca: ");
var busca = leitura.nextLine();
String endereco = "https://api.coingecko.com/api/v3/search?query=" + busca;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(endereco))
.build();
HttpResponse<String> response = client
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
RESPOSTA:
{"coins":[{"id":"bitcoin","name":"Bitcoin","api_symbol":"bitcoin","symbol":"BTC","market_cap_rank":1,"thumb":"https://assets.coingecko.com/coins/images/1/thumb/bitcoin.png","large":"https://assets.coingecko.com/coins/images/1/large/bitcoin.png"},{"id":"wrapped-bitcoin","name":"Wrapped Bitcoin","api_symbol":"wrapped-bitcoin","symbol":"WBTC","market_cap_rank":17,"thumb":"https://assets.coingecko.com/coins/images/7598/thumb/wrapped_bitcoin_wbtc.png","large":"https://assets.coingecko.com/coins/images/7598/large/wrapped_bitcoin_wbtc.png"},