Java SDK
cheap.serp:serpcheap は公式の Java クライアントです — Java 11 以上(JSON には Jackson を使用)。
インストール
Section titled “インストール”<dependency> <groupId>cheap.serp</groupId> <artifactId>serpcheap</artifactId> <version>0.1.0</version></dependency>クイックスタート
Section titled “クイックスタート”import cheap.serp.serpcheap.*;
SerpCheap client = new SerpCheap("YOUR_API_KEY");SearchResponse res = client.search(SearchParams.of("best running shoes"));
for (OrganicResult r : res.organic) { System.out.println(r.position + ". " + r.title + " — " + r.link);}パラメータとオプション
Section titled “パラメータとオプション”SearchParams params = SearchParams.builder() .q("best running shoes") .gl("us") // country (default "us") .hl("en") // UI language (optional) .tbs("qdr:w") // time filter (optional) .page(1) // 1-indexed (default 1) .build();
SerpCheap client = new SerpCheap("YOUR_API_KEY", ClientOptions.builder() .baseUrl("https://api.serp.cheap") .timeout(java.time.Duration.ofSeconds(15)) .maxRetries(2) .build());try { SearchResponse res = client.search(SearchParams.of("coffee"));} catch (SerpCheapException e) { System.err.println(e.getCode() + ": " + e.getMessage()); if (e.isRetryable()) { // transient — safe to try again later }}