> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The Zenrows HTTP API serves Fetch and Extract (extract=auto) at https://api.zenrows.com/v1/, Crawl at https://api.zenrows.com/v1/crawls, and Batch at https://async.api.zenrows.com/v1. Fetch, Extract, Crawl and Batch are described in OpenAPI 3.1 at https://www.zenrows.com/openapi.json and listed in the RFC 9727 API catalog at https://www.zenrows.com/.well-known/api-catalog. Every endpoint also has its own page under /api-reference with its schema. Use the spec for exact parameter names and types. Crawl's endpoints, parameters and errors are also at https://docs.zenrows.com/crawl/endpoints.md. To call Zenrows from an agent, connect the MCP server at https://mcp.zenrows.com/mcp. To search these docs from an agent, connect the docs MCP server at https://docs.zenrows.com/mcp. Agent skills for Zenrows are published at https://github.com/ZenRows/cli and install with `npx skills add ZenRows/cli`.

# Making your first request with the Go SDK

> Make your first request with the Zenrows Go SDK in a few lines of code.

This guide makes a single GET request with the Zenrows Go SDK: create a client, send the request, read the response.

> [!NOTE]
>
> Haven't installed the SDK yet? Follow [Installation](https://docs.zenrows.com/fetch/sdk/go/installation.md) first.

## Basic usage

**1. Create a client**

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

```go theme={null} theme={"theme":"css-variables"}
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:

```go theme={null} theme={"theme":"css-variables"}
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`.

> [!TIP]
>
> See [The Response Object](https://docs.zenrows.com/fetch/sdk/go/response-object.md) for everything available on it.

**3. Add request parameters**

Pass a `*scraperapi.RequestParameters` instead of `nil` to enable Fetch features like JavaScript rendering or Premium Proxies:

```go theme={null} theme={"theme":"css-variables"}
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())
}
```

> [!TIP]
>
> `RequestParameters` exposes every parameter documented in the [Fetch setup guide](https://docs.zenrows.com/fetch/setup.md), 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:

```go theme={null} theme={"theme":"css-variables"}
if response.IsSuccess() {
    fmt.Println(response.String())
} else {
    fmt.Println("Request failed with status", response.StatusCode())
}
```

See [Error Handling and Retries](https://docs.zenrows.com/fetch/sdk/go/error-handling-and-retries.md) 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 Playground with no extra whitespace. See [`AUTH002`](https://docs.zenrows.com/api-error-codes#auth002-invalid-api-key).

  [Open the Playground](https://app.zenrows.com/fetch)

* **`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`](https://docs.zenrows.com/api-error-codes#reqs002-request-requirements-unsatisfied).

* **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](https://docs.zenrows.com/fetch/sdk/go/async-concurrency.md).

## Pricing

Cost depends on the parameters you send, not on the SDK itself:

| Configuration | Credits per request |
| - | - |
| Basic request (no `JSRender`/`UsePremiumProxies`) | 1 |
| `JSRender: true` | 5 |
| `UsePremiumProxies: true` | 10 |
| `JSRender: true` + `UsePremiumProxies: true` | 25 |

Only successful requests are billed. See [Zenrows Pricing](https://docs.zenrows.com/first-steps/pricing.md) for exact per-plan rates.

## FAQ (Frequently Asked Questions)

> [accordion] Do I need to pass params for every request?
>
> No, passing `nil` is valid, it's the same as an empty `&scraperapi.RequestParameters{}`.

> [accordion] Why doesn't a failed request return a Go error?
>
> By design, the SDK returns a `*Response` even for error status codes. Check `response.IsSuccess()` or `response.StatusCode()` yourself. See [Error Handling and Retries](https://docs.zenrows.com/fetch/sdk/go/error-handling-and-retries.md).

> [accordion] Can I reuse the same client for multiple requests?
>
> 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

> [card] [POST and PUT Requests](https://docs.zenrows.com/fetch/sdk/go/post-put-requests.md)
>
> Submit forms or data payloads.

> [card] [Concurrency](https://docs.zenrows.com/fetch/sdk/go/async-concurrency.md)
>
> Scrape many URLs in parallel.

> [card] [Custom Headers](https://docs.zenrows.com/fetch/sdk/go/custom-headers.md)
>
> Forward specific headers to the target site.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.