Skip to content

About

Java 21 client on java.net.http with no dependency for live web search and page extraction, with drop-in Google Custom Search, Bing v7, Tavily and Exa routes on one key. Spring Boot ready. $1 per 1,000 searches.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java client for live web search, page extraction and the Google CSE, Bing, Tavily and Exa APIs

A Java 21 client on java.net.http.HttpClient with no dependency, for SpecStream, the live web data engine. One key answers SpecStream's own Search and Extract APIs and the drop-in routes that speak Google Custom Search, Bing Web Search v7, Tavily and Exa in their own request and reply shapes. Drop it into a Spring Boot service as one bean.

Method Route on https://api.specstream.ai Key goes Reply you read
webSearch GET /v1/web-search Authorization: Bearer data.sources[]
extract POST /v1/extract Authorization: Bearer data.results[], page text as Markdown
googleCse GET /customsearch/v1 key= in the address items[]
bing GET /v7.0/search Ocp-Apim-Subscription-Key webPages.value[]
tavily POST /tavily/search Authorization: Bearer results[]
exa POST /exa/search x-api-key results[]

Every search runs on the fast tier: $1 per 1,000 searches, 937 ms median over 6,548 live calls in the 7 days to December 1, 2026. Google ends the Custom Search JSON API on January 1, 2027, and Microsoft retired the Bing Search APIs in August 2025; both requests answer here unchanged. SpecStream is first on WideSearch and scores 99 on SimpleQA Verified.

Run

git clone https://github.com/specstream/java-spring-specstream-search
cd java-spring-specstream-search
javac -d out $(find src/main -name '*.java')
java -cp out ai.specstream.Main check        # live, no key, nothing charged
API reachable: 70 drop-in APIs on 78 routes at https://api.specstream.ai
  Google Custom Search JSON API    replaces https://www.googleapis.com
  Tavily                           replaces https://api.tavily.com
  Exa                              replaces https://api.exa.ai
  Bing Web Search API v7           replaces https://api.bing.microsoft.com/v7.0/search
  ready list:    204755 rows  /data/nonprofits/california

Or with Maven: mvn -q package && java -jar target/specstream-search-1.0.0.jar check.

Get a key under Agents & API at specstream.ai/workspace. A new account gets $2 of credit with no card, which is 2,000 fast searches.

export SPECSTREAM_API_KEY=your_key
java -cp out ai.specstream.Main search "Spring Boot 3.4 release notes"
java -cp out ai.specstream.Main extract https://openjdk.org/projects/jdk/21/
java -cp out ai.specstream.Main cse "best crm for startups"
java -cp out ai.specstream.Main bing "best crm for startups"
java -cp out ai.specstream.Main tavily "best crm for startups"
java -cp out ai.specstream.Main exa "best crm for startups"

In your code

Copy the two files in src/main/java/ai/specstream (SpecStream.java, Json.java) or install the jar with mvn install.

SpecStream ss = SpecStream.fromEnv(); // reads SPECSTREAM_API_KEY

for (var s : ss.webSearch("latest PostgreSQL release notes", 10)) {
    System.out.println(s.title() + " " + s.url());
}

var pages = ss.extract(List.of("https://www.postgresql.org/docs/release/"));
System.out.println(pages.get(0).text()); // Markdown, also from PDFs and Office files

In Spring Boot, one shared client is enough, as HttpClient is thread safe:

@Configuration
class SpecStreamConfig {
    @Bean
    SpecStream specStream(@Value("${specstream.api-key}") String key) {
        return new SpecStream(key);
    }
}

@RestController
class SearchController {
    private final SpecStream specStream;

    SearchController(SpecStream specStream) {
        this.specStream = specStream;
    }

    @GetMapping("/search")
    List<SpecStream.Source> search(@RequestParam String q) {
        return specStream.webSearch(q, 10);
    }
}

Every field of a reply is read null safe: a missing or null value comes back as an empty string or zero, never a NullPointerException. A reply outside 2xx throws SpecStream.ApiException with the status and the body in that route's own error shape, so a Bing caller still reads InvalidAuthorization and a Tavily caller still reads detail.error.

Moving code you already have

Keep your client and change the base address:

- https://www.googleapis.com/customsearch/v1?key=GOOGLE_KEY&cx=CX&q=...
+ https://api.specstream.ai/customsearch/v1?key=SPECSTREAM_KEY&q=...
- https://api.bing.microsoft.com/v7.0/search
+ https://api.specstream.ai/v7.0/search
- https://api.tavily.com/search
+ https://api.specstream.ai/tavily/search
- https://api.exa.ai/search
+ https://api.specstream.ai/exa/search

ss.dialects() lists all 70 APIs SpecStream answers, live, each with the address it replaces and a cURL line. SerpApi, Serper, Brave, Firecrawl and Jina Reader are among them.

Prices

Price
Free credit on sign-up $2, which is 2,000 fast searches, no card
Fast search, every drop-in route $1 per 1,000
Extract API, page text as Markdown $0.80 per 1,000 pages
Monthly Pro Pass $49 a month: 5,000 ready list rows a month and $49 of API credit

Links

License

MIT

About

Java 21 client on java.net.http with no dependency for live web search and page extraction, with drop-in Google Custom Search, Bing v7, Tavily and Exa routes on one key. Spring Boot ready. $1 per 1,000 searches.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages