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

# Go

> Install the Go v2 SDK, scrape a webpage, and retrieve brand data.

The [Go SDK](https://github.com/context-dot-dev/context-go-sdk) requires Go 1.22 or newer. Use the `/v2` module path.

## Install the SDK

In a new project directory, initialize a module. Skip this command if the project already has a `go.mod`:

```bash theme={null}
go mod init example.com/context-quickstart
```

Install the SDK:

```bash theme={null}
go get github.com/context-dot-dev/context-go-sdk/v2
```

## Set your API key

Get a secret API key from the [dashboard](https://context.dev/dashboard). Set it in the terminal where you will run the example:

```bash theme={null}
export CONTEXT_DEV_API_KEY="ctxt_secret_..."
```

Keep the key in server-side code. Do not expose it in a browser or commit it to source control.

## Scrape a webpage

Save this as `main.go`:

```go main.go theme={null}
package main

import (
    "context"
    "fmt"
    "os"

    contextdev "github.com/context-dot-dev/context-go-sdk/v2"
    "github.com/context-dot-dev/context-go-sdk/v2/option"
    "github.com/context-dot-dev/context-go-sdk/v2/packages/param"
)

func main() {
    client := contextdev.NewClient(
        option.WithAPIKey(os.Getenv("CONTEXT_DEV_API_KEY")),
    )

    response, err := client.Web.WebScrapeMd(
        context.TODO(),
        contextdev.WebWebScrapeMdParams{
            URL:                "https://example.com",
            UseMainContentOnly: param.NewOpt(true),
        },
    )
    if err != nil {
        panic(err)
    }

    fmt.Println(response.Markdown)
}
```

Run it from the module directory:

```bash theme={null}
go run main.go
```

## Check the result

The example prints the page content as Markdown. Look for the `Example Domain` heading; the remaining text and formatting may vary.

```markdown Expected heading theme={null}
# Example Domain
```

If you receive an error, check the key and request details in [Troubleshooting](/optimization/troubleshooting). See the [Markdown API reference](/api-reference/web-scraping/markdown) for all parameters and response fields.

## Retrieve brand data

In `main`, replace the Markdown request, error check, and print statement with this lookup:

```go theme={null}
response, err := client.Brand.Get(
    context.TODO(),
    contextdev.BrandGetParams{
        OfByDomain: &contextdev.BrandGetParamsBodyByDomain{
            Domain: "stripe.com",
        },
    },
)
if err != nil {
    panic(err)
}

fmt.Println(response.Brand.Title)
```

Remove the `packages/param` import if you no longer use it. The example prints the matched company name.

The older unversioned Go module, last checked at `v1.5.0`, uses a legacy Brand request. Upgrade the dependency and imports to `/v2` to use the unified `POST /brand/retrieve` endpoint, or make a direct HTTP request.

## Next steps

<CardGroup cols={2}>
  <Card title="Scrape a webpage" icon="globe" href="/guides/scrape-websites-to-markdown">
    Choose which page content to include.
  </Card>

  <Card title="Retrieve brand data" icon="palette" href="/guides/get-brand-data">
    Look up profiles with other company identifiers.
  </Card>
</CardGroup>
