Skip to content

feat: add markdown() for the md output format, bump to 1.2.0 - #7

Merged
jvmvik merged 4 commits into
masterfrom
feat/markdown-output
Aug 16, 2026
Merged

feat: add markdown() for the md output format, bump to 1.2.0#7
jvmvik merged 4 commits into
masterfrom
feat/markdown-output

Conversation

@jvmvik

@jvmvik jvmvik commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

What

SerpApi's output parameter accepts md — 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:

String md = client.get("/search", "md", parameter);

This adds markdown(), mirroring html():

public String markdown(Map<String, String> parameter) throws SerpApiException {
  return get("/search", "md", parameter);
}

Also corrects the get() javadoc, which listed the formats as (json, html, json_with_images) where the API documents (json, html, md).

Tests

MarkdownApiTest stubs the HTTP client with a recorder and asserts on the request this client builds — that output=md is sent, that the path is /search, and that constructor defaults (api_key, engine) still merge into the query. Runs offline, no SERPAPI_KEY needed.

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 md works is the documentation plus a markdown_endpoint field observed in live search_metadata. Someone with a key should sanity-check an actual call before this ships.

Two other points worth a reviewer's eye:

  • Path choice. html() posts to /client, not /search. I used /search for markdown since that is what the docs describe, but if /client is the intended route for non-JSON output, this should match it.
  • Error visibility. 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 in json(). Given md is aimed at agent use, silently returning an error body as if it were content may matter more here than for html(). 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.gradle 1.1.0 → 1.2.0
  • README installation snippet and changelog (template and generated file)
  • 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 visible to callers.

demo/build.gradle still 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.

jvmvik and others added 3 commits August 15, 2026 22:10
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>
@jvmvik jvmvik changed the title feat: add markdown() for the md output format feat: add markdown() for the md output format, bump to 1.2.0 Aug 16, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jvmvik jvmvik self-assigned this Aug 16, 2026
@jvmvik
jvmvik merged commit 46851aa into master Aug 16, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant