Skip to content

[SCR-583] Use header-based authorization + document all API params - #23

Open
sahilsunny wants to merge 3 commits into
mainfrom
sahil/scr-583-update-python-sdk-to-support-header-based-authorization
Open

[SCR-583] Use header-based authorization + document all API params#23
sahilsunny wants to merge 3 commits into
mainfrom
sahil/scr-583-update-python-sdk-to-support-header-based-authorization

Conversation

@sahilsunny

Copy link
Copy Markdown
Contributor

Moves auth from the api_key query param to the Authorization: Bearer header — keeps keys out of URLs and server logs. The API has supported this on all endpoints since SCR-463, and the header wins when both are sent, so nothing breaks. No interface change: ScrapingBeeClient(api_key=...) works exactly as before.

While at it, the README now documents every request parameter for every endpoint, taken straight from the server-side schemas. That includes tag (accepted everywhere), custom_google (still required for Google URLs — the API changelog note about its removal is inaccurate), nb_results, autoselect_variant, and the deprecated-but-still-accepted params, marked as such.

Tested: full suite updated (fails against the old client, passes against the new), plus live runs against production — usage, HTML API, Auto-Mode and fast_search all return 200 with the key present only in the header, and a wrong key gets a 401.

Version: 2.1.1 → 2.2.0

Auth: the client now sends the API key as an `Authorization: Bearer`
request header instead of the `api_key` query parameter, keeping keys
out of URLs and server logs. The server has accepted header auth on all
endpoints since SCR-463 (June 2026) and gives the header precedence, so
this is backward-compatible with all supported API versions.

Docs: add complete request-parameter tables for every endpoint (HTML,
Google Search, Fast Search, Amazon x3, Walmart x2, YouTube x3, ChatGPT,
Gemini), sourced from the server-side param schemas. This includes
`tag` (accepted everywhere), `custom_google` (still required for Google
URLs — the API changelog's "removed" note is incorrect), `nb_results`,
`autoselect_variant`, and deprecated-but-accepted params, marked as
such. Also documents Auto-Mode's transparent_status_code exclusion and
the Usage API rate limit.

Tests: all client assertions moved from api_key-in-params to the
Authorization header; suite fails against the old client and passes
against the new one. Verified live against production: usage, HTML API,
Auto-Mode, fast_search all 200 with the key absent from the URL, and a
wrong key returns 401.

Version: 2.1.1 -> 2.2.0.
@sahilsunny
sahilsunny requested a review from a team August 18, 2026 04:07
- Remove proxy_mode from the README: it is in the server's private schema,
  and documenting it publicly invites an API-key leak (with proxy_mode +
  forward_headers the server forwards the raw Authorization header to the
  scraped site).
- Fix swapped types (Google min_price/max_price are floats, radius is an
  int), correct the Amazon country note (400 when it matches the domain
  country, not a silent no-op), annotate missing defaults, exclude Usage
  from the tag note, and add renewal_subscription_date to the usage sample.
- Send the ScrapingBee-Python User-Agent on all endpoints (previously only
  HTML API requests had it).
- Add auth invariant tests: every method must authenticate via the Bearer
  header with no api_key query param, and a caller-supplied Authorization
  header cannot clobber authentication (it forwards as Spb-Authorization).
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