Decodo Python SDK

The official Python SDK for the Decodo Web Scraping API.
Build scraping workflows for search engines, eCommerce platforms, social media, AI tools, and more using the Decodo Web Scraping API.
- Fully typed targets and parameters with IDE autocomplete
- Sync, async, and batch scraping methods
- Built on
httpx, Python 3.10+
- Typed error hierarchy for safer integrations
- Built for Python and modern tooling
What is Decodo Python SDK?
Decodo Python SDK is the official Python SDK for the Decodo Web Scraping API. It provides a typed interface for interacting with Decodo targets like Google, Amazon, TikTok, YouTube, ChatGPT, Perplexity, and more.
Instead of manually constructing HTTP requests and validating payloads, you can work with fully typed methods and target-specific parameters directly in your editor.
Why use the SDK?
- Typing and autocomplete. Target parameters are fully typed for better DX and fewer mistakes.
- Unified scraping interface. Work with search engines, eCommerce platforms, social media, and AI tools through one SDK.
- Async and batch workflows. Create scraping tasks, poll statuses, and process batches at scale.
- Typed errors. Handle authentication, validation, timeout, and rate-limit failures safely.
- Minimal setup. Single dependency on
httpx, no additional HTTP client required.
Requirements
Installation
pip install decodo-sdk
Quick start
Create a new project:
mkdir scrape-with-decodo
cd scrape-with-decodo
pip install decodo-sdk
touch main.py
Copy your Web Data API key from your Web Data API subscription on the Decodo dashboard. Older plans only have a basic authentication token, which you can pass as token instead (see Configuration).
Every target has a corresponding parameter class. Import the one you need, fill in its fields, and pass it to scrape():
# main.py
from decodo import (
DecodoClient,
DecodoConfig,
GoogleSearchParams,
WebScrapingApiConfig,
)
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
api_key="<api_key>",
),
)
)
result = client.web_scraping_api.scrape(
GoogleSearchParams(
query="coffee shops",
geo="United States",
parse=True,
)
)
print(result)
Run the script:
python main.py
Parameter classes are bundled with the package, so no extra step is needed after pip install decodo-sdk. Each class pins its own target and accepts only the fields that target supports. Your IDE can flag misspelled or unsupported fields, while runtime validation catches them before the request is sent.
GoogleSearchParams is the parameter class for Target.GoogleSearch. The naming follows a simple pattern covered in Targets and parameter classes.
Alternative: dictionary payloads
Scraping methods also accept a plain Python dictionary. The payload is validated against the bundled schema before the request is sent, but nothing is checked while you write the code, so typos and unsupported fields surface only at runtime:
result = client.web_scraping_api.scrape({
"target": "google_search",
"query": "coffee shops",
"geo": "United States",
"parse": True,
})
print(result)
Use the Target enum instead of a raw string to avoid mistyping the target name:
from decodo import Target
result = client.web_scraping_api.scrape({
"target": Target.GoogleSearch,
"query": "coffee shops",
"parse": True,
})
print(result)
Typed parameters are recommended for anything beyond a quick experiment. The rest of this README uses the typed parameter approach throughout.
Updating types to a newer schema
The types bundled in the package reflect the schema at release time. To update them to the latest schema without waiting for a new release, run the type generator:
python -m decodo.codegen.codegen --out-dir ./decodo_generated
Then import from that directory instead:
from decodo_generated.targets import GoogleSearchParams
The directory name passed to --out-dir becomes the import namespace. ./decodo_generated → from decodo_generated.targets import .... You can use any name, but keep it consistent across your project.
Example response
{
"results": [
{
"content": {
"results": {
"last_visible_page": 10,
"page": 1,
"parse_status_code": 12000,
"results": {
"local_pack": [
{
"items": [
{
"address": "Rochester, NY",
"paid": false,
"pos": 1,
"rating": 4.9,
"rating_count": 1700,
"subtitle": "Coffee shop",
"title": "Albunn Coffee House"
},
{
"address": "Rochester, NY",
"paid": false,
"pos": 2,
"rating": 4.8,
"rating_count": 937,
"subtitle": "Coffee shop",
"title": "Layali Coffee House"
},
{
"address": "Ocean Township, NJ",
"paid": false,
"pos": 3,
"rating": 4.9,
"rating_count": 124,
"subtitle": "Coffee shop",
"title": "Ocean Brew Co."
}
],
"pos_overall": 1
}
],
"organic": [
{
"desc": "For an alternate, local view, Eater has an interesting list of what it considers Philadelphia's 21 Essential Coffee Shops.",
"pos": 1,
"pos_overall": 2,
"title": "Philadelphia",
"url": "https://www.brian-coffee-spot.com/the-coffee-spot-guide-to/usa-canada/philadelphia/"
}
],
"search_information": {
"query": "coffee shops",
"total_results_count": 403000000
}
},
"url": "https://www.google.com/search?q=coffee+shops&hl=en&gl=us"
},
"errors": [],
"status_code": 12000,
"task_id": "7463508496927950850"
},
"status_code": 200,
"url": "https://www.google.com/search?q=coffee+shops&hl=en&gl=us",
"task_id": "7463508496927950850",
"created_at": "2026-05-22 08:38:10",
"updated_at": "2026-05-22 08:38:13"
}
]
}
Configuration
from decodo import (
DecodoClient,
DecodoConfig,
WebScrapingApiConfig,
)
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
api_key="<api_key>",
),
timeout_ms=120_000, # optional, request timeout in ms (default: 180000)
)
)
Pass either api_key or token, not both. The client raises ValueError if you set both.
# Basic auth token (older plans)
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
token="<basic_auth_token>",
),
)
)
| Parameter |
Description |
api_key |
Web Data API key. Recommended |
token |
Web Scraping API basic auth token for older plans, the base64-encoded user:password string from the Decodo dashboard. Use it instead of api_key |
timeout_ms |
Request timeout in milliseconds (default: 180000) |
Web Scraping API
Access the API via client.web_scraping_api.
The snippets below assume you have already constructed a client. See Configuration for how to build one.
Sync scrape
Waits for the scraping result before returning:
from decodo import (
AmazonProductParams,
DecodoClient,
DecodoConfig,
WebScrapingApiConfig,
)
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
api_key="<api_key>",
),
)
)
# Run the scrape and wait for the result.
result = client.web_scraping_api.scrape(
AmazonProductParams(
query="B09H74FXNW",
parse=True,
)
)
# Print the completed response.
print(result)
Async scrape
Creates a scraping task and returns immediately, then you poll for status and results:
import time
from decodo import (
DecodoClient,
DecodoConfig,
GoogleSearchParams,
WebScrapingApiConfig,
)
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
api_key="<api_key>",
),
)
)
# Submit the scraping task and return immediately.
task = client.web_scraping_api.scrape_async(
GoogleSearchParams(
query="laptop reviews",
parse=True,
)
)
# Save the returned task ID.
task_id = task["id"]
# Poll until the task finishes.
while True:
status = client.web_scraping_api.get_status(task_id)["status"]
if status == "done":
break
if status == "faulted":
raise RuntimeError(f"Scraping task {task_id} failed.")
time.sleep(2)
# Retrieve and print the completed result.
result = client.web_scraping_api.get_results(task_id)
print(result)
get_status returns pending, done, or faulted.
Batch scrape
Send multiple inputs in a single request. Batch calls use the batch variant of the target's parameter class, where the primary input accepts a list:
import time
from decodo import (
DecodoClient,
DecodoConfig,
GoogleSearchBatchParams,
WebScrapingApiConfig,
)
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
api_key="<api_key>",
),
)
)
# Submit multiple queries in a single batch request.
# For another target, use its batch parameter class and primary input.
batch = client.web_scraping_api.scrape_batch(
GoogleSearchBatchParams(
query=["coffee", "tea", "juice"],
parse=True,
)
)
# Wait for each task and print its completed result.
for task in batch["queries"]:
task_id = task["id"]
while True:
status = client.web_scraping_api.get_status(task_id)["status"]
if status == "done":
break
if status == "faulted":
raise RuntimeError(f"Scraping task {task_id} failed.")
time.sleep(2)
result = client.web_scraping_api.get_results(task_id)
print(result)
Data API: search, map and crawl
These endpoints are served by the Data API at data.decodo.com and need an api_key. Calling them on a client configured with a basic auth token raises ValueError saying an API key is required. They live on the same client.web_scraping_api namespace.
Parameters are plain dictionaries. The SearchRequest, MapRequest and CrawlRequest types are TypedDicts you can use for editor completion; they are always importable and need no code generation. Bodies are validated against the bundled schema before the request is sent, like scrape.
Search
Runs a web search and returns the parsed result document:
from decodo import DecodoClient, DecodoConfig, SearchRequest, WebScrapingApiConfig
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
api_key="<api_key>",
),
)
)
result = client.web_scraping_api.search(
SearchRequest(query="coffee shops", geo="United States", page=1)
)
for item in result.get("organic", []):
print(item["rank"], item["title"], item["link"])
A search that ran but could not be scraped still answers with HTTP 200 and status: "failed" plus a message, so check result["status"] before reading the fields.
Map
Discovers the links on a site, from its pages and sitemap:
from decodo import DecodoClient, DecodoConfig, MapRequest, WebScrapingApiConfig
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
api_key="<api_key>",
),
)
)
result = client.web_scraping_api.map(
MapRequest(url="https://www.example.com", limit=100, sitemap="include")
)
for link in result["results"][0]["content"]["links"]:
print(link["url"])
Crawl
crawl starts a crawl, waits for it to finish and returns every page with its content:
from decodo import (
CrawlError,
CrawlInterruptedError,
CrawlRequest,
CrawlTimeoutError,
DecodoClient,
DecodoConfig,
WebScrapingApiConfig,
)
client = DecodoClient(
DecodoConfig(
web_scraping_api=WebScrapingApiConfig(
api_key="<api_key>",
),
)
)
try:
pages = client.web_scraping_api.crawl(
CrawlRequest(url="https://www.example.com", limit=20, max_depth=2),
poll_interval=5,
timeout=600,
)
except CrawlTimeoutError as err:
print(f"Still running, fetch it later with get_crawl_results({err.crawl_id!r})")
except CrawlError as err:
print(f"Crawl {err.crawl_id} ended {err.status}: {err.reason}")
else:
for page in pages:
print(page["url"], page["status"], page.get("content", "")[:80])
A crawl that stops early because of max_duration or a vendor limit ends with status truncated; crawl returns the pages it did collect. Pages are returned as the API lists them, each with its status (pending, done or faulted) and, when the fetch failed, a content_error instead of content.
The lower-level methods let you drive a crawl yourself, for example to start it in one process and collect it in another: