O mais difícil foi permitir a chave api, mas deu certo.
import java.io.IOException; 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 BuscaLivros { public static void main(String[] args) throws IOException, InterruptedException { Scanner leitura = new Scanner(System.in);
System.out.println("Digite o livro que quer buscar:");
var busca = leitura.nextLine();
String chave = "AIzaSyAHsA_uD5-PnHgTPU-X6KZ3OgZOLfhKv24";
String endereco = "https://www.googleapis.com/books/v1/volumes?q=" + busca + "&key=" + chave;
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());
}