View the Go SDK GitHub repository for the latest installation instructions, examples, and source code.
- 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 versionto check, or install Go.
Installation
Quick start
Create a new project:Older plans only have a basic authentication token. Set
Token instead of APIKey – see Configuration.Scrape:
Setting optional parameters
Optional parameters are pointer fields, so an unset field is distinguishable from a zero value. Usedecodo.Ptr to set them inline:
Configuration
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 viaclient.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 asNewGoogleSearchBatchParams(). 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 atdata.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.
Search
Map
Crawl
Crawl starts a crawl, polls until it settles, and returns every page:
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 withNew, 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.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 noSchema 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.
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.Related
- 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.
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.
Have feedback? Share your thoughts on how we can improve.