Skip to main content
This guide makes a single GET request with the ZenRows Go SDK: create a client, send the request, read the response.
Haven’t installed the SDK yet? Follow Installation first.

Basic usage

1

Create a client

Import the scraperapi package and instantiate a client with your API key:
package main

import (
    scraperapi "github.com/zenrows/zenrows-go-sdk/service/api"
)

func main() {
    client := scraperapi.NewClient(
        scraperapi.WithAPIKey("YOUR_ZENROWS_API_KEY"),
    )
}
2

Send a GET request

Call client.Get() with a context.Context and the URL you want to scrape:
package main

import (
    "context"
    "fmt"
    "log"

    scraperapi "github.com/zenrows/zenrows-go-sdk/service/api"
)

func main() {
    client := scraperapi.NewClient(
        scraperapi.WithAPIKey("YOUR_ZENROWS_API_KEY"),
    )

    response, err := client.Get(context.Background(), "https://www.scrapingcourse.com/ecommerce/", nil)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(response.String())
}
response is a *scraperapi.Response, a thin wrapper that also exposes the original *http.Response.
See The Response Object for everything available on it.
3

Add request parameters

Pass a *scraperapi.RequestParameters instead of nil to enable Universal Scraper API features like JavaScript rendering or Premium Proxies:
package main

import (
    "context"
    "fmt"
    "log"

    scraperapi "github.com/zenrows/zenrows-go-sdk/service/api"
)

func main() {
    client := scraperapi.NewClient(
        scraperapi.WithAPIKey("YOUR_ZENROWS_API_KEY"),
    )

    response, err := client.Get(context.Background(), "https://www.scrapingcourse.com/ecommerce/", &scraperapi.RequestParameters{
        JSRender:          true,
        UsePremiumProxies: true,
        ProxyCountry:      "us",
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(response.String())
}
RequestParameters exposes every parameter documented in the Universal Scraper API setup guide, including AutoParse, CSSExtractor, WaitForSelector, BlockResources, and Outputs. They all work exactly the same way through the SDK.
4

Check the result

Since the SDK doesn’t turn a non-2xx response into a Go error, always check the status before using the content:
if response.IsSuccess() {
    fmt.Println(response.String())
} else {
    fmt.Println("Request failed with status", response.StatusCode())
}
See Error Handling and Retries for how to configure automatic retries so you don’t have to handle every transient failure manually.

Troubleshooting

  • response.StatusCode() is 401 or similar auth error: Double-check your API key was copied correctly from the ZenRows Request Builder with no extra whitespace. See AUTH002.
  • response.String() is empty or looks like an error page, not the target site: The target likely needs JSRender: true and/or UsePremiumProxies: true. See REQS002.
  • Request hangs for a long time: Pass a context.Context created with context.WithTimeout(...). We recommend not going below 3 minutes for protected sites using JSRender.
  • 429 Too Many Requests: You’ve hit your plan’s concurrency or rate limit. See Concurrency.

Pricing

Cost depends on the parameters you send, not on the SDK itself:
ConfigurationCost multiplier vs. basic
Basic request (no JSRender/UsePremiumProxies)1x
JSRender: true5x
UsePremiumProxies: true10x
JSRender: true + UsePremiumProxies: true25x
Only successful requests are billed. See ZenRows Pricing for exact per-plan rates.

FAQ (Frequently Asked Questions)

No, passing nil is valid, it’s the same as an empty &scraperapi.RequestParameters{}.
By design, the SDK returns a *Response even for error status codes. Check response.IsSuccess() or response.StatusCode() yourself. See Error Handling and Retries.
Yes. Create one *scraperapi.Client and call .Get()/.Post()/.Put() on it as many times as needed, there’s no need to recreate it per request. It’s also safe to share across goroutines.

What’s next

POST and PUT Requests

Submit forms or data payloads.

Concurrency

Scrape many URLs in parallel.

Custom Headers

Forward specific headers to the target site.