Skip to content

fix: request html() from /search instead of the nonexistent /client endpoint - #13

Merged
tanysheng merged 1 commit into
masterfrom
fix/html-endpoint
Sep 23, 2026
Merged

tanysheng merged 1 commit into
masterfrom
fix/html-endpoint

Conversation

@tanysheng

@tanysheng tanysheng commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Problem

SerpApi.html() sends its request to /client, which does not exist on serpapi.com. Every call gets the site's 404 HTML page back, and then fails with:

SerpApiException: invalid response format: <!DOCTYPE html> ...

Raw HTML is served from /search with output=html. That is the same endpoint search() (output=json) and markdown() (output=md) already use.

GET https://serpapi.com/client?output=html&...  -> 404 (HTML page)
GET https://serpapi.com/search?output=html&...  -> handled by the Search API

No test covered html(), so nothing caught it. It came up while reviewing #11, which documents client.html(parameter) under Features and Response Formats.

Change

  • SerpApi.html() now calls get("/search", "html", parameter).
  • Adds an offline test, HtmlApiTest, modeled on MarkdownApiTest. It stubs the HTTP client and checks the path and the output=html value. No network call or SERPAPI_KEY is needed.

Verification

  • With the old /client path, HtmlApiTest.htmlRequestsHtmlOutputFromSearchEndpoint fails (expected:</[search]> but was:</[client]>). With the fix it passes.
  • The other offline tests (HtmlApiTest, MarkdownApiTest, ErrorResponseTest, ParameterStringBuilderTest, TimeoutTest) all pass.
  • End to end against serpapi.com with a deliberately invalid key:
    • before: invalid response format: <!DOCTYPE html>... (the 404 page)
    • after: Invalid API key. Your API key should be here: ... (the request now reaches the Search API)

@tanysheng
tanysheng merged commit 6167b1c into master Sep 23, 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