feat: add markdown() for the md output format, bump to 1.2.0 - #7
Merged
Conversation
SerpApi accepts output=md, "a markdown-formatted version optimized for
LLMs and AI agents", but this client exposed no way to ask for it short
of calling the low-level get("/search", "md", parameter) and knowing the
endpoint path.
Add markdown(), mirroring html(): the raw String is returned unparsed.
Also correct the get() javadoc, which listed the output formats as
(json, html, json_with_images) where the API documents (json, html, md).
Tests stub the HTTP client and assert on the request this client builds,
so they run offline without a SERPAPI_KEY.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Drop the intro and trailing note, and follow the auth/parameter naming and the "it prints ..." closing line used by the surrounding sections. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bump the project version and the places that restate it: - build.gradle, which names the published artifact - README installation snippet and changelog, in both the erb template and the generated README.md - SerpApiHttp.VERSION, which had drifted to 1.0.0 while the project was at 1.1.0. It is public and never read anywhere in the library, so the stale value was only ever visible to callers. demo/build.gradle still pins 1.0.0 and is left alone, since it resolves a published JitPack artifact rather than this source tree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
SerpApi's
outputparameter acceptsmd— per the Search API docs, "a markdown-formatted version optimized for LLMs and AI agents" — but this client exposed no way to ask for it. Reaching it meant dropping to the low-level call and knowing the endpoint path:This adds
markdown(), mirroringhtml():Also corrects the
get()javadoc, which listed the formats as(json, html, json_with_images)where the API documents(json, html, md).Tests
MarkdownApiTeststubs the HTTP client with a recorder and asserts on the request this client builds — thatoutput=mdis sent, that the path is/search, and that constructor defaults (api_key,engine) still merge into the query. Runs offline, noSERPAPI_KEYneeded.Please verify before merging
I have not confirmed a real markdown response end-to-end. I have no API key in this environment, so the tests assert what we send, not what the backend returns. The evidence that
mdworks is the documentation plus amarkdown_endpointfield observed in livesearch_metadata. Someone with a key should sanity-check an actual call before this ships.Two other points worth a reviewer's eye:
html()posts to/client, not/search. I used/searchfor markdown since that is what the docs describe, but if/clientis the intended route for non-JSON output, this should match it.markdown()returns a raw String, so it bypasses the body-level error check proposed in fix: raise SerpApiException on an error in a 200 response body #6, which lives injson(). Givenmdis aimed at agent use, silently returning an error body as if it were content may matter more here than forhtml(). Left as-is to keep this PR focused.🤖 Generated with Claude Code
Also in this PR: version bump to 1.2.0
Folded in rather than shipped separately:
build.gradle1.1.0 → 1.2.0SerpApiHttp.VERSION, which had drifted to 1.0.0 while the project was at 1.1.0. It is public and never read anywhere in the library, so the stale value was only visible to callers.demo/build.gradlestill pins 1.0.0 and is deliberately untouched: it resolves a published JitPack artifact, and 1.2.0 does not exist there until this is released.