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 for Web Scraping API.
  • Typed, target-specific request parameters with editor autocomplete
  • Sync, async, and batch scraping methods
  • 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, Reddit, 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:
Get your Web Scraping API Basic Auth token from the Decodo dashboard. Keep it out of your source by exporting it:
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

Web Scraping API

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.Some targets aren’t available through ScrapeBatch. Use ScrapeAsync for those instead. Batch requests are limited to one per second and skip schema validation because the schema describes single values.

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_searchNewGoogleSearchParams(). 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

Universal scraping

universal_ecommerce isn’t included in the table because its parameter struct exposes only Target and CallbackURL, with no primary input. Use ecommerce for generic product pages or 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 locally for 24 hours. If the fetch fails, 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.
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 Web Scraping API into TypeScript and JavaScript projects.
  • Python SDK – Integrate the Web Scraping API 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.