Skip to main content

Official Python SDK for the Decodo APIs

Project description

Decodo Python SDK

Python License

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.12+
  • 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, Reddit, 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

  • Python 3.12+

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

Get your Web Scraping API token from the Decodo dashboard. The token is the base64-encoded user:password value from the Basic Auth credentials shown in the dashboard.

# main.py
from decodo import DecodoClient, DecodoConfig, WebScrapingApiConfig

client = DecodoClient(
    DecodoConfig(
        web_scraping_api=WebScrapingApiConfig(token="<basic_auth_token>"),
    )
)

result = client.web_scraping_api.scrape({
    "target": "google_search",
    "query": "coffee shops",
    "geo": "United States",
    "parse": True,
})
print(result)

Run the script:

python main.py

With typed parameters (recommended)

Typed parameter classes are included in the package — no extra steps needed after pip install decodo-sdk:

from decodo import DecodoClient, DecodoConfig, GoogleSearchParams, Target, WebScrapingApiConfig

client = DecodoClient(
    DecodoConfig(
        web_scraping_api=WebScrapingApiConfig(token="<basic_auth_token>"),
    )
)

result = client.web_scraping_api.scrape(
    GoogleSearchParams(
        target=Target.GoogleSearch,
        query="coffee shops",
        geo="United States",
        parse=True,
    )
)
print(result)

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_generatedfrom 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(token="<basic_auth_token>"),
        timeout_ms=120_000,  # optional, request timeout in ms (default: 180000)
    )
)
Parameter Description
token Web Scraping API basic auth token - the base64-encoded user:password string from the Decodo dashboard
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:

result = client.web_scraping_api.scrape({
    "target": "amazon_product",
    "query": "B09H74FXNW",
    "parse": True,
})

Async scrape

Creates a scraping task and returns immediately. Poll separately for task status and results:

task = client.web_scraping_api.scrape_async({
    "target": "google_search",
    "query": "laptop reviews",
    "parse": True,
})

meta = client.web_scraping_api.get_status(task["id"])
print(meta["status"])  # 'pending' | 'done' | 'faulted'

results = client.web_scraping_api.get_results(task["id"])

Batch scrape

Send multiple queries or URLs in a single request:

batch = client.web_scraping_api.scrape_batch({
    "target": "google_search",
    "query": ["coffee", "tea", "juice"],
    "parse": True,
})

coffee_task_id = batch["queries"][0]["id"]

client.web_scraping_api.get_results(coffee_task_id)

Supported targets

Each target accepts one primary input parameter (url, query, product_id, or prompt) together with optional configuration. The examples below show the minimum payload to call client.web_scraping_api.scrape(...).

Search engines

Target Description Example
Target.GoogleSearch Google Search results for a query {"target": Target.GoogleSearch, "query": "coffee shops"}
Target.GoogleMaps Google Maps search results {"target": Target.GoogleMaps, "query": "coffee shops brooklyn"}
Target.GoogleShoppingSearch Google Shopping search results {"target": Target.GoogleShoppingSearch, "query": "laptop"}
Target.GoogleShoppingProduct Google Shopping product page {"target": Target.GoogleShoppingProduct, "query": "B09H74FXNW"}
Target.GoogleSuggest Google Autocomplete suggestions {"target": Target.GoogleSuggest, "query": "coffee"}
Target.GoogleLens Google Lens reverse image search {"target": Target.GoogleLens, "query": "https://example.com/cat.jpg"}
Target.GoogleTravelHotels Google Travel hotel listings {"target": Target.GoogleTravelHotels, "query": "hotels in paris"}
Target.GoogleTrendsExplore Google Trends explore data {"target": Target.GoogleTrendsExplore, "query": "coffee"}
Target.GoogleAds Google Ads results for a query {"target": Target.GoogleAds, "query": "laptop"}
Target.BingSearch Bing Search results {"target": Target.BingSearch, "query": "electric vehicles"}
Target.Bing Raw Bing URL scraping {"target": Target.Bing, "url": "https://bing.com/search?q=laptop"}

eCommerce

Target Description Example
Target.AmazonProduct Amazon product detail page by ASIN {"target": Target.AmazonProduct, "query": "B09H74FXNW"}
Target.AmazonSearch Amazon search results {"target": Target.AmazonSearch, "query": "laptop"}
Target.AmazonPricing Amazon pricing and offers {"target": Target.AmazonPricing, "query": "B09H74FXNW"}
Target.AmazonSellers Amazon seller listings {"target": Target.AmazonSellers, "query": "B09H74FXNW"}
Target.AmazonBestsellers Amazon bestsellers by category {"target": Target.AmazonBestsellers, "query": "electronics"}
Target.WalmartProduct Walmart product page by product ID {"target": Target.WalmartProduct, "product_id": "15296401808"}
Target.WalmartSearch Walmart search results {"target": Target.WalmartSearch, "query": "laptop"}
Target.Walmart Raw Walmart URL scraping {"target": Target.Walmart, "url": "https://walmart.com/ip/15296401808"}
Target.TargetProduct Target.com product page by product ID {"target": Target.TargetProduct, "product_id": "92186007"}
Target.TargetSearch Target.com search results {"target": Target.TargetSearch, "query": "laptop"}
Target.Target Raw Target.com URL scraping {"target": Target.Target, "url": "https://target.com/p/-/A-92186007"}
Target.LowesSearch Lowe's search results {"target": Target.LowesSearch, "query": "drill"}
Target.Ecommerce Generic eCommerce page with parser {"target": Target.Ecommerce, "url": "https://example.com/product/123"}

Social media

Target Description Example
Target.RedditPost Reddit post by URL {"target": Target.RedditPost, "url": "https://reddit.com/r/nba/..."}
Target.RedditSubreddit Reddit subreddit by URL {"target": Target.RedditSubreddit, "url": "https://reddit.com/r/nba/"}
Target.RedditUser Reddit user profile by URL {"target": Target.RedditUser, "url": "https://reddit.com/user/example/"}
Target.YoutubeVideo YouTube video by ID {"target": Target.YoutubeVideo, "query": "dFu9aKJoqGg"}
Target.YoutubeSearch YouTube search results {"target": Target.YoutubeSearch, "query": "ambient music"}
Target.YoutubeSearchMax YouTube search results (extended) {"target": Target.YoutubeSearchMax, "query": "ambient music"}
Target.YoutubeMetadata YouTube video metadata by ID {"target": Target.YoutubeMetadata, "query": "dFu9aKJoqGg"}
Target.YoutubeTranscript YouTube video transcript by ID {"target": Target.YoutubeTranscript, "query": "dFu9aKJoqGg"}
Target.YoutubeSubtitles YouTube video subtitles by ID {"target": Target.YoutubeSubtitles, "query": "dFu9aKJoqGg"}
Target.YoutubeChannel YouTube channel by URL {"target": Target.YoutubeChannel, "url": "https://youtube.com/@mkbhd"}
Target.TiktokPost TikTok post by URL {"target": Target.TiktokPost, "url": "https://www.tiktok.com/@nba/video/..."}
Target.TiktokShopSearch TikTok Shop search results {"target": Target.TiktokShopSearch, "query": "wireless earbuds"}
Target.TiktokShopProduct TikTok Shop product page {"target": Target.TiktokShopProduct, "url": "https://www.tiktok.com/view/product/..."}
Target.Tiktok Raw TikTok URL scraping {"target": Target.Tiktok, "url": "https://www.tiktok.com/@nba"}
Target.InstagramGraphqlProfile Instagram profile via GraphQL {"target": Target.InstagramGraphqlProfile, "query": "nba"}

AI tools

Target Description Example
Target.Chatgpt ChatGPT response for a prompt {"target": Target.Chatgpt, "prompt": "What are the top three dog breeds?"}
Target.Perplexity Perplexity response for a prompt {"target": Target.Perplexity, "prompt": "What causes seasonal allergies?"}
Target.Gemini Gemini response for a prompt {"target": Target.Gemini, "prompt": "What are the top three dog breeds?"}
Target.GoogleAiMode Google AI Mode response {"target": Target.GoogleAiMode, "query": "What are the top three dog breeds?"}

Other

Target Description Example
Target.Bbb Better Business Bureau listing by URL {"target": Target.Bbb, "url": "https://bbb.org/us/ny/new-york/..."}
Target.Autotrader Autotrader listing by URL {"target": Target.Autotrader, "url": "https://autotrader.com/cars-for-sale/..."}
Target.Mobile Mobile.de listing by URL {"target": Target.Mobile, "url": "https://mobile.de/auto/..."}
Target.Airbnb Airbnb listing by URL {"target": Target.Airbnb, "url": "https://airbnb.com/rooms/12345"}
Target.AppleAppStore Apple App Store app by URL {"target": Target.AppleAppStore, "url": "https://apps.apple.com/app/id12345"}

Universal scraping

Target Description Example
Target.Universal Any URL via the universal scraper {"target": Target.Universal, "url": "https://example.com"}
Target.Google Raw Google URL scraping {"target": Target.Google, "url": "https://google.com/search?q=laptop"}
Target.Amazon Raw Amazon URL scraping {"target": Target.Amazon, "url": "https://amazon.com/dp/B09H74FXNW"}

Target.UniversalEcommerce isn't listed above because it doesn't accept a primary input parameter like url, query, product_id, or prompt. It only accepts optional configuration fields such as callback_url.

For the full target list and parameter details, see the API documentation:

Error handling

The SDK raises typed errors that map to API error codes:

from decodo import (
    AuthenticationError,
    RateLimitError,
    ValidationError,
    TimeoutError,
)

try:
    client.web_scraping_api.scrape({
        "target": "google_search",
        "query": "test",
        "parse": True,
    })
except AuthenticationError:
    pass  # 401/403 - bad credentials
except RateLimitError:
    pass  # 429 - too many requests
except ValidationError as err:
    print(err.errors)  # 422 - invalid parameters
except TimeoutError:
    pass  # request timed out

Related repositories

Get started

Build scraping workflows with the Decodo Web Scraping API:

License

Released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

decodo_sdk-2.2.0.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

decodo_sdk-2.2.0-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

File details

Details for the file decodo_sdk-2.2.0.tar.gz.

File metadata

  • Download URL: decodo_sdk-2.2.0.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for decodo_sdk-2.2.0.tar.gz
Algorithm Hash digest
SHA256 6d53638e12875f313090a1ecd684f448c61329a6fd9f94c78f95cfad4acc5163
MD5 e62732fdbbaab4ed0837e4f66c5b8ca6
BLAKE2b-256 3323cc7f6ac8fa859b26d16e5411e6afdb5367ea066d061ca5b442ae7a338911

See more details on using hashes here.

Provenance

The following attestation bundles were made for decodo_sdk-2.2.0.tar.gz:

Publisher: worklfow.yml on Decodo/sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file decodo_sdk-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: decodo_sdk-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 38.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for decodo_sdk-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c67edb5e63b62ade7d8636666da8aceafe703cffd2b901dbe3e499ca6b1d7821
MD5 b458664608e172ecf1da4edca41357ca
BLAKE2b-256 4fc215be860186fb04f06aaf2b2080fd84732d7a1f1add1885193598973b07a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for decodo_sdk-2.2.0-py3-none-any.whl:

Publisher: worklfow.yml on Decodo/sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page