11# JustSerpAPI Java SDK
22
3- Java SDK for the JustSerpAPI HTTP interface. The SDK is generated from the upstream OpenAPI document and republished through GitHub and Maven Central .
3+ Official Java SDK for [ JustSerpAPI] ( https://justserpapi.com/ ) .
44
5- ## What This Repository Contains
5+ Use this SDK to access JustSerpAPI from Java and fetch structured Google search results without building raw HTTP requests by hand.
66
7- - Checked-in raw and normalized OpenAPI specs under ` openapi/ `
8- - Checked-in generated Java sources under ` src/main/generated/ `
9- - A stable entry point, ` JustSerpApiClient ` , under ` src/main/java/ `
10- - GitHub Actions for CI, scheduled spec sync PRs, and tag-based releases
7+ Get your API key, product docs, and pricing at [ justserpapi.com] ( https://justserpapi.com/ ) .
118
129## Requirements
1310
1411- Java 11+
15- - Python 3.9+
16- - Maven 3.9+
1712
18- ## Install
13+ ## Installation
1914
2015``` xml
2116<dependency >
@@ -25,61 +20,81 @@ Java SDK for the JustSerpAPI HTTP interface. The SDK is generated from the upstr
2520</dependency >
2621```
2722
28- Replace the version with the latest published release.
29-
30- ## Usage
23+ ## Quick Start
3124
3225``` java
3326import com.justserpapi.JustSerpApiClient ;
27+ import com.justserpapi.generated.invoker.ApiException ;
3428import com.justserpapi.model.JustSerpApiResponse ;
3529
3630import java.time.Duration ;
3731
3832public class Example {
39- public static void main (String [] args ) throws Exception {
33+ public static void main (String [] args ) throws ApiException {
4034 JustSerpApiClient client = JustSerpApiClient . builder()
4135 .apiKey(System . getenv(" JUSTSERPAPI_API_KEY" ))
4236 .timeout(Duration . ofSeconds(30 ))
4337 .build();
4438
45- JustSerpApiResponse response = client. google(). autocomplete(" coffee" , null , null );
46- System . out. println(response. getCode());
47- System . out. println(response. getData());
39+ JustSerpApiResponse response = client. google(). search(
40+ " coffee shops in shanghai" ,
41+ 0 ,
42+ false ,
43+ " en" ,
44+ null ,
45+ " google.com" ,
46+ " us" ,
47+ null ,
48+ null ,
49+ null ,
50+ null ,
51+ null ,
52+ null ,
53+ null ,
54+ null ,
55+ null ,
56+ null ,
57+ " off" ,
58+ " 0" ,
59+ " 1"
60+ );
61+
62+ System . out. println(" code = " + response. getCode());
63+ System . out. println(" message = " + response. getMessage());
64+ System . out. println(" requestId = " + response. getRequestId());
65+ System . out. println(" organic results = " + response. getData(). get(" organic_results" ));
4866 }
4967}
5068```
5169
52- ` JustSerpApiClient ` configures base URL, timeout, user agent, and API key injection. Operation methods are generated from the normalized OpenAPI document and exposed through ` client.google() ` .
53-
54- ## Regenerate The SDK
70+ ## Configuration
5571
56- Fetch the live OpenAPI document, normalize it, regenerate the SDK, and sync checked-in generated sources:
57-
58- ``` bash
59- python3 scripts/sync_sdk.py
72+ ``` java
73+ JustSerpApiClient client = JustSerpApiClient . builder()
74+ .apiKey(" YOUR_API_KEY" )
75+ .baseUrl(" https://api.justserpapi.com" )
76+ .timeout(Duration . ofSeconds(30 ))
77+ .build();
6078```
6179
62- Rebuild from the checked-in normalized spec without hitting the network:
80+ ` apiKey(...) ` is required. ` baseUrl(...) ` and ` timeout(...) ` are optional.
6381
64- ``` bash
65- python3 scripts/sync_sdk.py --skip-fetch
66- ```
67-
68- Verify that the generated sources are already up to date:
82+ ## Response Format
6983
70- ``` bash
71- python3 scripts/sync_sdk.py --skip-fetch --check
72- ```
84+ Every request returns a ` JustSerpApiResponse ` envelope:
7385
74- Run the local build:
86+ - ` code ` : application-level status code
87+ - ` message ` : response message
88+ - ` requestId ` : server request id
89+ - ` timestamp ` : epoch milliseconds
90+ - ` data ` : endpoint-specific payload
7591
76- ``` bash
77- mvn verify
78- ```
92+ ## Documentation
7993
80- ## Release Flow
94+ - Website: [ https://justserpapi.com/ ] ( https://justserpapi.com/ )
95+ - API docs: [ https://justserpapi.com/ ] ( https://justserpapi.com/ )
96+ - GitHub releases: [ https://github.com/justserpapi/justserpapi-java/releases ] ( https://github.com/justserpapi/justserpapi-java/releases )
8197
82- - Daily scheduled workflow fetches the upstream OpenAPI document and opens a PR when the normalized spec or generated sources change.
83- - Pushing a Git tag that matches ` v* ` runs the publish workflow.
84- - Maven Central publishing and signing setup is documented in [ docs/publishing.md] ( /Users/tianxingzhou/project/justserpapi-java/docs/publishing.md ) .
98+ ## Support
8599
100+ For account setup, API access, and product information, start at [ justserpapi.com] ( https://justserpapi.com/ ) .
0 commit comments