Skip to main content
View the Go SDK GitHub repository for the latest installation instructions, examples, and source code.
Build typed scraping workflows for search engines, eCommerce platforms, social media, AI tools, and more with the official Decodo Go SDK.
  • Typed, target-specific request parameters with editor autocomplete
  • Sync, async, and batch scraping methods
  • Web search, site mapping, and crawling through the Web Data API
  • Runtime validation against the current Decodo target schema
  • Typed error set for safer integrations
  • One dependency beyond the standard library; requires Go 1.21 or later

What is the Decodo Go SDK?

The Decodo Go SDK provides a typed interface for interacting with Decodo targets like Google, Amazon, TikTok, YouTube, ChatGPT, Perplexity, and more. Instead of assembling HTTP requests and validating payloads by hand, you work with typed constructors and target-specific parameter structs directly in your editor.

Why use the SDK?

  • Typing and autocomplete – each target has its own parameter struct, so your editor knows which fields it accepts.
  • 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 task status, and process batches at scale.
  • Typed errors – handle authentication, validation, timeout, and rate-limit failures explicitly.
  • Generated from the schema – target constants and parameter structs are generated from the Decodo schema, which is also used for runtime validation.
  • Minimal setup – one dependency for schema validation, and the standard library for everything else.

Requirements

  • Go 1.21 or later. Run go version to check, or install Go.

Installation

Quick start

Create a new project:
Copy your Web Data API key from your Web Data API subscription on the Decodo dashboard. Keep it out of your source by exporting it:
Older plans only have a basic authentication token. Set Token instead of APIKey – see Configuration.
Every target has a constructor that returns its parameter struct. Create the one you need, set its fields, and pass it to Scrape:
Run the program:
Each constructor pins its own target and returns a struct that carries only the fields that target supports, so you never pass a target name or assemble a generic parameter map. Your editor flags misspelled or unsupported fields, and the SDK validates values against the target schema before sending the request.

Setting optional parameters

Optional parameters are pointer fields, so an unset field is distinguishable from a zero value. Use decodo.Ptr to set them inline:

Configuration

Set either APIKey or Token, never both:
Setting both returns a *decodo.ConfigurationError: WebScrapingAPI accepts either Token or APIKey, not both. The credential also decides which API the SDK calls: APIKey uses the Web Data API at data.decodo.com, which is the only way to reach Search, Map, and Crawl. Token uses the older Web Scraping API at scraper-api.decodo.com, which supports scraping only.

Scraping

Access the API via client.WebScrapingAPI.

Sync scrape

Waits for the scraping result before returning:

Async scrape

Creates a scraping task and returns immediately. You then poll for its status and results:
GetStatus returns one of decodo.TaskStatusPending, decodo.TaskStatusDone, or decodo.TaskStatusFaulted. GetResults returns nil until results are available.

Batch scrape

Every supported target also has a batch constructor, such as NewGoogleSearchBatchParams(). For batch requests, fields such as URL or Query accept a slice, with each value becoming a separate task:
A batch runs against a single target, which the constructor pins for you. URL and Query are the only fields that accept multiple values; all other fields use their regular types.ScrapeBatch doesn’t support walmart_product, target_product, tiktok_shop_product, chatgpt, gemini, or perplexity. Use ScrapeAsync for those instead. Batch requests are limited to one per second and skip schema validation because the schema describes single values.

Web Data API: Search, Map, and Crawl

These methods are served by the Web Data API at data.decodo.com and require APIKey. Calling one on a client configured with a basic authentication Token returns a *decodo.ConfigurationError before any request is sent, for example: Search requires an API key. Configure WebScrapingAPIConfig.APIKey instead of Token. Match it with errors.As.

Map

Crawl

Crawl starts a crawl, polls until it settles, and returns every page:
To drive a crawl yourself, start it and poll separately:
GetCrawlResults follows the API’s pagination internally and returns every page, so there is no separate list-pages call. The TypeScript SDK’s listCrawlPages has no Go equivalent.Crawl wraps its failures, so match them with errors.As rather than a type switch - see Error handling.

Targets and parameter constructors

Every target has a matching constructor. The target name is converted to PascalCase, prefixed with New, and suffixed with Params – for example, google_search → NewGoogleSearchParams(). Batch constructors follow the same pattern, for example NewGoogleSearchBatchParams(). You don’t need to pass a target explicitly because each constructor pins its own target. Each parameter struct also carries a Target field, and GetTarget() returns it as a string. Each target takes one primary input field (URL, Query, ProductID, or Prompt) together with optional configuration such as Parse, Markdown, Geo, or CallbackURL. Available optional fields vary by target, so use editor autocomplete or the parameters documentation.

Search engines

eCommerce

Social media

AI tools

Other

Universal and raw URL scraping

The Go SDK ships 40 targets. Coverage differs between the Decodo SDKs, so a target available in the TypeScript SDK isn’t necessarily available here - ecommerce, universal_ecommerce, google_maps, google_suggest, google_shopping_search, youtube_video, and youtube_transcript have no constructor in Go. Use universal for any URL.
For the full target list and parameter details, see Target list and Parameters.

Schema validation

Go checks that a field exists and holds the right type at compile time. Values are checked separately, at runtime, against the Decodo target schema. When no Schema is configured, the client uses decodo.SharedDefaultSchema, which loads the latest schema on first use and caches it at ~/.decodo/decodo.ir.json for 24 hours. The load runs once per process, so a failed fetch is not retried: the SDK logs a warning and continues with validation disabled for that session.

Error handling

The SDK returns typed errors that map to API error codes:
AuthenticationError, RateLimitError, and ValidationError embed DecodoError and implement Unwrap. As a result, errors.Is and errors.As also work with *decodo.DecodoError.
A type switch only matches the error’s own type. Crawl wraps its failures, so a type switch sends them all to default. Use errors.As for anything that can come back from a crawl:
TimeoutError and CancellationError sit outside the DecodoError hierarchy and only carry Msg, so checks against *decodo.DecodoError won’t match them.Schema validation may also be skipped if the target schema can’t be fetched. In that case, invalid values may reach the API and be returned as API errors instead of compile-time or local validation errors.

  • CLI – Run Decodo scraping workflows from the command line.
  • TypeScript SDK – Integrate the Decodo APIs into TypeScript and JavaScript projects.
  • Python SDK – Integrate the Decodo APIs into Python projects.
  • MCP Server – Connect AI agents and MCP-compatible tools to Decodo.
  • GitHub repository – View the Go SDK source code, examples, and latest releases.

Support

Need help or just want to say hello? Our support is available 24/7.
You can also reach us anytime via email at support@decodo.com.

Feedback

Can’t find what you’re looking for? Request an article!
Have feedback? Share your thoughts on how we can improve.