| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Add markdown support, improve error handling if corrupt data received.
dependencies {
implementation 'com.github.serpapi:serpapi-java:1.2.0'
}markdown() returns search results in the md output format, intended for LLM and agent consumption. Previously this required dropping to the low-level get("/search", "md", parameter) and knowing the endpoint path.
Map<String, String> auth = new HashMap<>();
auth.put("api_key", "your_api_key");
auth.put("engine", "google");
SerpApi serpapi = new SerpApi(auth);
Map<String, String> parameter = new HashMap<>();
parameter.put("q", "coffee");
System.out.println(serpapi.markdown(parameter));The raw markdown String is returned unparsed, like html().
This is a breaking behavior change.
SerpApi reports some failures in the body of an HTTP 200 response:
{
"search_metadata": { "status": "Success" },
"search_information": { "events_results_state": "Fully empty" },
"error": "Google hasn't returned any results for this query."
}The client previously decided success from the status code alone, so search() returned an object that was semantically an error. Callers then reached for the key they expected and got a NullPointerException in their own code, while the explanation sat unread in the error field.
search(), account(), searchArchive() and location() now raise SerpApiException carrying that message, whatever the status code.
If you currently inspect the returned object for an error field yourself, that branch is now unreachable — catch SerpApiException instead. html() and markdown() are unaffected, since both return raw Strings.
SerpApi.timeout was applied only to the connection timeout, leaving the read timeout at its 60s default. That is backwards: connecting takes milliseconds, while 60s to read is tight for engines that scrape. Searches against slow engines — home_depot especially — intermittently failed with:
SerpApiException: java.net.http.HttpTimeoutException: request timed out
The timeout now applies to both connecting and reading, and the default is 120s. To restore the previous bound, set timeout before issuing a search.
Full changelog: 1.1.0...1.2.0
Full Changelog: 1.0.0...1.1.0
| Back | FazBrowse Home | New Git URL |