ScrapingBee is a web scraping API that handles headless browsers and rotates proxies for you. The Python SDK makes it easier to interact with ScrapingBee's API.
Installation
You can install ScrapingBee Python SDK with pip.
pip install scrapingbee
Usage
The ScrapingBee Python SDK is a wrapper around the requests library.
Signup to ScrapingBee to get your API key and some free credits to get started.
Authentication
Pass your API key to the client constructor. Since version 2.2.0 the SDK authenticates via the Authorization: Bearer <api_key> request header (previously the api_key query parameter), keeping your key out of URLs and server logs.
from scrapingbee import ScrapingBeeClient
client = ScrapingBeeClient(api_key='YOUR-API-KEY')
Common parameters
Every endpoint (except Usage, which takes no parameters) additionally accepts an optional tag parameter (string, max 36 characters, letters/digits/-/_/spaces) to label requests for your own analytics.
With Auto-Mode, ScrapingBee picks the cheapest scraping configuration that successfully scrapes the page for you: it tries the cheaper options first and stops at the first one that works. You are charged only for the winning configuration (and 0 credits if every configuration fails).
>>> from scrapingbee import ScrapingBeeClient
>>> client = ScrapingBeeClient(api_key='REPLACE-WITH-YOUR-API-KEY')
# Auto-Mode: ScrapingBee picks the cheapest config that works; you're charged only for the winning one.
>>> response = client.html_api(
'https://example.com',
method='GET',
params={
'mode': 'auto',
# Optional: cap the credits a single request may cost (omit for uncapped).
'max_cost': 25
}
)
# Spb-auto-cost reports the credits actually charged (0 if every config failed).
>>> response.headers['Spb-auto-cost']
'1'
Notes:
Auto-Mode is only available on GET requests.
max_cost is optional and must be >= 1; omit it to leave the cost uncapped. Sending max_cost without mode=auto returns a 400.
mode=auto cannot be combined with render_js, premium_proxy, stealth_proxy (ScrapingBee chooses these for you) or transparent_status_code. Sending them together returns a 400.
HTML API Parameters
Parameters accepted on both GET and POST requests:
Parameter
Type
Description
url
string
Required. The URL to scrape (set automatically from the first argument).
ai_query
string
AI query describing what to extract (max 300 chars).
ai_selector
string
CSS selector to narrow AI extraction (max 100 chars).
ai_extract_rules
dict
AI extraction rules (the SDK JSON-stringifies dicts for you).
cookies
dict
Cookies to forward (pass via the cookies= argument; the SDK formats them).
country_code
string
Country to proxy the request from.
extract_rules
dict
CSS/XPath extraction rules (the SDK JSON-stringifies dicts for you).
forward_headers
bool
Forward your headers to the target (set automatically when you pass headers=).
forward_headers_pure
bool
Forward headers without ScrapingBee's defaults.
json_response
bool
Wrap the response in JSON with extra metadata.
own_proxy
string
Use your own proxy (protocol://user:password@host:port).
premium_proxy
bool
Use premium (residential) proxies.
scraping_config
string
Name of a saved scraping configuration (max 32 chars).
session_id
int
Reuse the same proxy across requests.
timeout
int
Request timeout in ms (1000–141000).
transparent_status_code
bool
Return the target's HTTP status code as-is.
Parameters accepted on GET requests only:
Parameter
Type
Description
block_ads
bool
Block ads when rendering JavaScript.
block_resources
bool
Block images and CSS when rendering JavaScript.
custom_google
bool
Required (True) when scraping Google domains — a 400 is returned if a google.* URL is sent without it, or if it is set on a non-Google URL.
device
string
desktop (default) or mobile.
js_scenario
dict
Browser instructions to execute (the SDK JSON-stringifies dicts for you).
Required. The search query (set automatically from the first argument).
add_html
bool
Include the raw HTML in the response.
country_code
string
Country to search from (default us).
date_range
string
past_hour, past_day, past_week, past_month or past_year.
device
string
desktop or mobile (mobile is not available with search_type=news).
extra_params
string
Extra Google query-string params; allowed keys: filter, fpstate, locale, nfpr, safe, safe_search, tbm, tbs, udm.
language
string
Deprecated — accepted but ignored.
latitude / longitude
float
Geo-target results; must be provided together.
light_request
bool
Lighter, cheaper scrape (default True).
min_price / max_price
float
Price filters; only with search_type=shopping.
nb_results
int
Number of results to request (default 10; capped at 20 for search_type=maps).
nfpr
bool
Disable auto-corrected spelling results.
page
int
Result page to fetch (default 1).
pages
int
Number of pages to fetch (1–10, default 1).
radius
int
Search radius; requires latitude/longitude.
search_type
string
classic (default), news, maps, images, lens, shopping, ai_mode or ads. For lens, search must be an image URL; for ai_mode, search is capped at 400 chars.
sort_by
string
relevance, reviews, price_asc or price_desc; only with search_type=shopping.
Fast Search API
Lightweight Google search results in under a second.
response = client.fast_search(
search='pizza in new york',
params={
'country_code': 'us',
'language': 'en',
'page': 1
}
)
print(response.json())
Fast Search Parameters
Parameter
Type
Description
search
string
Required. The search query (set automatically from the first argument).
country_code
string
Country to search from (default us).
language
string
Deprecated — accepted but ignored.
page
int
Result page to fetch (>= 1).
Amazon API
Scrape Amazon search results, product details, and pricing.
Include the raw HTML in the response (default False).
country
string
Country to geo-target. Only takes effect when domain is not set — on search/product domain defaults to com, so country there is either rejected with a 400 (when it matches the domain's country) or ignored. Effective on pricing only (where us is the default and ignored).
currency
string
Currency for prices.
domain
string
Amazon domain, e.g. com, co.uk (default com on search/product, unset on pricing).
language
string
Result language.
light_request
bool
Lighter, cheaper scrape (default True).
zip_code
string
Zip code to geo-target offers.
Endpoint-specific:
Parameter
Type
Endpoints
Description
query
string
search, product
Required. Search terms (search) or a 10-char ASIN (product).
asin
string
pricing
Required. 10-char ASIN ([A-Z0-9]{10}).
autoselect_variant
bool
search, product
Auto-select the default product variant.
category_id
string
search
Restrict results to a category.
device
string
all
desktop (all); product also allows mobile and tablet.
merchant_id
string
search
Restrict results to a merchant.
pages
int
search
Number of pages to fetch (default 1).
screenshot
bool
search, product
Return a screenshot.
sort_by
string
search
most_recent, price_low_to_high, price_high_to_low, featured, average_review or bestsellers (default bestsellers).
start_page
int
search
First page to fetch (default 1).
Walmart API
Scrape Walmart search results and product details.
Python SDK for Firecrawl: search, scrape, parse, crawl, map, and interact with the web, run Agent and Monitor jobs, and search scientific papers (PubMed, bioRxiv, medRxiv, arXiv)