Skip to content

Add markdown() output support and Doxygen documentation - #6

Merged
jvmvik merged 2 commits into
mainfrom
new-md-endpoint
Aug 16, 2026
Merged

Add markdown() output support and Doxygen documentation#6
jvmvik merged 2 commits into
mainfrom
new-md-endpoint

Conversation

@jvmvik

@jvmvik jvmvik commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Client::markdown() — new method returning search results as Markdown, alongside the existing html(). Requests /search with output=md.
  • Version 0.4.1 → 0.5.0 in meson.build and the VERSION source tag (minor bump for a new public method).
  • Doxygen comments on every method in serpapi.cpp (@brief/@param/@return), plus a Doxyfile so doxygen Doxyfile generates HTML docs into docs/ (gitignored).
  • README — usage example, changelog entry, class diagram, download command bumped to v0.5.0, and a coverage-results section.
  • Testclient.markdown in test/test_serpapi.cpp, mirroring the existing client.html test.

Why output=md

SerpApi documents three equivalent ways to request Markdown. I verified all three against the live API — each returns HTTP 200, text/markdown, and byte-identical bodies (34,885 bytes for the same query):

Method Result
output=md query parameter 200 ✅
/search.md endpoint 200 ✅
Accept: text/markdown header 200 ✅

output=md is the one that fits the existing get(uri, output, parameter) plumbing — the other two would need path special-casing or new header support for no functional difference.

The response is YAML frontmatter (search_metadata) followed by ## sections (Organic Results, Knowledge Graph, Ai Overview, …), formatted for LLM/agent consumption.

Verification

Built and tested against current main with -Dtests=true, with SERPAPI_KEY set so the live-API tests actually execute:

  • 23/23 tests pass, including client.markdown (865 ms, green)
  • Coverage: lines 78.0%, functions 100% (15/15), branches 45.9%

Notes for reviewers

  • This supersedes the markdown commits I previously pushed to docs/download-command. That branch's PR (docs: add curl download command to README #5) was already merged, so those commits were stranded and never reached main. This branch is a clean rebase of the same work onto current main. docs/download-command can be deleted.
  • Follow-up not included here: the Markdown response advertises a markdown_endpoint, and /searches/<id>.md works (verified, 200) — but search_archive() hardcodes .json and returns a rapidjson::Document, so archived searches can't be fetched as Markdown. Worth a follow-up; it needs an API-naming decision (markdown_archive(id) vs. an output param on search_archive).
  • The README download command now follows main's newer archive/refs/tags/ tarball format, just bumped to v0.5.0.

🤖 Generated with Claude Code

jvmvik and others added 2 commits August 16, 2026 12:22
Add Client::markdown() alongside html() for the new /md output format,
bump the package version to 0.5.0, and document every serpapi.cpp
method with Doxygen-style comments. Also adds a Doxyfile for
generating HTML docs from src/ and the README.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Records the current rake coverage output (lines, functions, branches)
so contributors have a quick reference without re-running it locally.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jvmvik
jvmvik merged commit 21ac067 into main Aug 16, 2026
1 check passed
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