Go SDK
Overview
The official Scrapeless Go SDK provides access to browser automation, scraping, crawling, proxies, search results, and AI chat extraction. This guide follows the SDK repository README, with runnable examples and configuration details.
Requirements
Go 1.24.0 or later is required by the repository’s go.mod. Run the installation command inside a Go module. For a new project, initialize one with go mod init example.com/scrapeless-demo.
Installation
go get -u github.com/scrapeless-ai/sdk-goAuthentication / API Key
Log in to the Scrapeless dashboard and create an API key. Export it before running the examples:
export SCRAPELESS_API_KEY="YOUR_API_KEY"Keep your API key in your environment or secret manager instead of committing it to source control.
Quick Start
Save this as main.go and run go run . after setting your API key. Enable each service with its corresponding With...() option and close the client when finished.
package main
import (
"context"
"fmt"
"log"
"github.com/scrapeless-ai/sdk-go/scrapeless"
"github.com/scrapeless-ai/sdk-go/scrapeless/services/universal"
)
func main() {
client := scrapeless.New(scrapeless.WithUniversal())
defer client.Close()
result, err := client.Universal.CreateTask(context.Background(), universal.UniversalTaskRequest{
Actor: universal.ScraperUniversal,
Input: map[string]any{
"url": "https://example.com",
"method": "GET",
"redirect": false,
},
})
if err != nil {
log.Print(err)
return
}
fmt.Printf("%+v\n", result)
}Product Coverage Matrix
| Product | SDK service | Enable with | Coverage |
|---|---|---|---|
| Scraping Browser | client.Browser | scrapeless.WithBrowser() | Create and manage remote browser sessions. |
| Browser Profiles | client.Profile | scrapeless.WithProfile() | Persist browser data across sessions. |
| Scraping API | client.Scraping | scrapeless.WithScraping() | Extract structured data using website actors. |
| Web Unlocker | client.Universal | scrapeless.WithUniversal() | Retrieve content from protected websites. |
| Crawl | client.Crawl | scrapeless.WithCrawl() | Scrape a page or crawl a website. |
| Google Search API | client.DeepSerp | scrapeless.WithDeepSerp() | Extract search engine results. |
| Proxies | client.Proxy | scrapeless.WithProxy() | Generate proxy connection URLs. |
| AI Scraper | client.AIScraper | scrapeless.WithAIScraper() | Create AI chat tasks and retrieve their status and results. |
Services are opt-in. For example, initialize both browser and AI Scraper support with scrapeless.New(scrapeless.WithBrowser(), scrapeless.WithAIScraper()). The README also documents Client.Captcha, Client.Server, and Client.Router for additional workflows.
Usage Examples
Browser
package main
import (
"context"
"github.com/scrapeless-ai/sdk-go/scrapeless"
"github.com/scrapeless-ai/sdk-go/scrapeless/log"
"github.com/scrapeless-ai/sdk-go/scrapeless/services/browser"
)
func main() {
client := scrapeless.New(scrapeless.WithBrowser())
defer client.Close()
browserInfo, err := client.Browser.Create(context.Background(), browser.Actor{
Input: browser.Input{SessionTtl: "180"},
ProxyCountry: "US",
})
if err != nil {
panic(err)
}
log.Infof("%+v", browserInfo)
}Browser Profile
package main
import (
"context"
"fmt"
"github.com/scrapeless-ai/sdk-go/scrapeless"
)
func main() {
client := scrapeless.New(scrapeless.WithProfile())
defer client.Close()
result, err := client.Profile.CreateProfile(context.Background(), "My Profile")
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", result)
}Scraping API
package main
import (
"context"
"github.com/scrapeless-ai/sdk-go/scrapeless"
"github.com/scrapeless-ai/sdk-go/scrapeless/log"
"github.com/scrapeless-ai/sdk-go/scrapeless/services/scraping"
)
func main() {
client := scrapeless.New(scrapeless.WithScraping())
defer client.Close()
scrape, err := client.Scraping.Scrape(context.Background(), scraping.ScrapingTaskRequest{
Actor: "scraper.google.search",
Input: map[string]interface{}{
"q": "nike site:www.nike.com",
},
ProxyCountry: "US",
})
if err != nil {
log.Errorf("scraping create err:%v", err)
return
}
log.Infof("%+v", scrape)
}Web Unlocker
Extract data from websites using Web Unlocker (exposed as client.Universal).
package main
import (
"context"
"fmt"
"github.com/scrapeless-ai/sdk-go/scrapeless"
"github.com/scrapeless-ai/sdk-go/scrapeless/services/universal"
)
func main() {
client := scrapeless.New(scrapeless.WithUniversal())
defer client.Close()
result, err := client.Universal.CreateTask(context.Background(), universal.UniversalTaskRequest{
Actor: universal.ScraperUniversal,
Input: map[string]any{
"url": "https://example.com",
"method": "GET",
"redirect": false,
},
})
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", result)
}Crawl
package main
import (
"context"
"github.com/scrapeless-ai/sdk-go/scrapeless"
"github.com/scrapeless-ai/sdk-go/scrapeless/log"
"github.com/scrapeless-ai/sdk-go/scrapeless/services/crawl"
)
func main() {
client := scrapeless.New(scrapeless.WithCrawl())
defer client.Close()
// Crawl
response, err := client.Crawl.CrawlUrl(context.Background(), "https://redditinc.com/blog", crawl.CrawlParams{
Limit: 10,
ScrapeOptions: crawl.ScrapeOptions{
Formats: []string{"links",
"markdown",
"html",
"screenshot"},
},
BrowserOptions: crawl.ICreateBrowser{
SessionName: "Crawl",
SessionTTL: "900",
SessionRecording: "true",
ProxyCountry: "ANY",
},
})
if err != nil {
panic(err)
}
log.Infof("Crawl response: %v", response)
// scrape
scrapeResponse, err := client.Crawl.ScrapeUrl(context.Background(), "https://docs.scrapeless.com/en/docs/get-started/overview/", crawl.ScrapeOptions{
BrowserOptions: crawl.ICreateBrowser{
SessionName: "Crawl",
SessionTTL: "900",
SessionRecording: "true",
ProxyCountry: "ANY",
},
})
if err != nil {
panic(err)
}
log.Infof("Scrape response: %v", scrapeResponse)
}Proxy
package main
import (
"context"
"fmt"
"github.com/scrapeless-ai/sdk-go/scrapeless"
"github.com/scrapeless-ai/sdk-go/scrapeless/services/proxies"
)
func main() {
client := scrapeless.New(scrapeless.WithProxy())
defer client.Close()
result, err := client.Proxy.Proxy(context.Background(), proxies.ProxyActor{
Country: "US",
SessionDuration: 30,
SessionId: "my-session",
Gateway: "your-proxy-gateway:port",
})
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", result)
}AI Scraper
Extract AI chat content in bulk to monitor brand mentions, compare answers, and analyze competitive intelligence from the latest models. Retrieve URLs, prompts, Markdown answers, citations, and more through one integration.
Supported actors include scraper.chatgpt, scraper.perplexity, scraper.copilot, scraper.gemini, scraper.aimode, scraper.overview, scraper.grok, and scraper.alexa. The input JSON depends on the actor; see the AI Scraper documentation for detailed parameters. The optional webhook JSON contains a callback url.
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/scrapeless-ai/sdk-go/scrapeless"
"github.com/scrapeless-ai/sdk-go/scrapeless/services/aiscraper"
)
func main() {
client := scrapeless.New(scrapeless.WithAIScraper()) // Uses SCRAPELESS_API_KEY
defer client.Close()
ctx := context.Background()
task, err := client.AIScraper.CreateTask(ctx, aiscraper.TaskRequest{
Actor: "scraper.chatgpt",
Input: map[string]any{
"prompt": "Most reliable proxy service for data extraction",
"country": "US",
"web_search": true,
},
// Optional: Webhook: map[string]any{"url": "https://your-webhook.example.com"},
})
if err != nil {
panic(err)
}
fmt.Println("Created task:", string(task))
var created struct {
TaskID string `json:"task_id"`
}
if err := json.Unmarshal(task, &created); err != nil {
panic(err)
}
result, err := client.AIScraper.GetTaskResult(ctx, created.TaskID)
if err != nil {
panic(err)
}
fmt.Println("Task status and result:", string(result))
// If status is "running", call GetTaskResult again later.
// If status is "failed", message contains the failure reason.
}Both methods return the API JSON unchanged. Creation returns task_id, status, and, when available, task_result. Result retrieval returns status, task_result when available, and message on failure. Status is success, failed, or running; the SDK does not poll automatically.
Responses are raw JSON bytes ([]byte), preserving every API field. Decode them with encoding/json as needed.
Google Search API
package main
import (
"context"
scrapeless "github.com/scrapeless-ai/sdk-go/scrapeless"
"github.com/scrapeless-ai/sdk-go/scrapeless/log"
"github.com/scrapeless-ai/sdk-go/scrapeless/services/deepserp"
)
func main() {
client := scrapeless.New(scrapeless.WithDeepSerp())
defer client.Close()
scrape, err := client.DeepSerp.Scrape(context.Background(), deepserp.DeepserpTaskRequest{
Actor: "scraper.google.search",
Input: map[string]interface{}{
"q": "nike site:www.nike.com",
},
ProxyCountry: "US",
})
if err != nil {
log.Errorf("scraping create err:%v", err)
return
}
log.Infof("%+v", scrape)
}For more complete integrations, browse the repository’s example directory.
Error Handling
Check the returned error before using a service response. Use a context deadline to bound individual requests and defer client.Close() to release client resources.
This example retrieves an existing AI Scraper task. Replace YOUR_TASK_ID with the ID returned by CreateTask.
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/scrapeless-ai/sdk-go/scrapeless"
)
func main() {
client := scrapeless.New(scrapeless.WithAIScraper())
defer client.Close()
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
result, err := client.AIScraper.GetTaskResult(ctx, "YOUR_TASK_ID")
if err != nil {
log.Printf("Could not retrieve task: %v", err)
return
}
fmt.Println(string(result))
}AI Scraper HTTP failures return an error. A successful HTTP request can still contain a task with status: "failed"; inspect the response’s status and message fields after decoding the JSON.
Configuration / Environment Variables
The API key is required. Endpoint overrides are optional; the table shows their defaults.
Set environment variables before starting the program. The SDK also reads a .env file from the working directory. AI Scraper requests have a 30-second HTTP timeout; use context.WithTimeout for a shorter per-request deadline.
| Environment variable | Purpose / default |
|---|---|
SCRAPELESS_API_KEY | Required API key from the dashboard. |
SCRAPELESS_BASE_API_URL | https://api.scrapeless.com |
SCRAPELESS_BROWSER_API_URL | https://browser.scrapeless.com |
SCRAPELESS_CRAWL_API_URL | https://api.scrapeless.com |
Support
- SDK source and README
- Report an issue
- Scrapeless documentation
- Join the Discord community
- Email support
The SDK is released under the MIT License.