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

# Go Code Samples

> Use ScreenshotMAX API in Go to capture website screenshots, automate rendering tasks, and securely generate images with signed API requests. Fast, reliable, and developer-friendly.

## ScreenshotMAX with Go

Use Go to interact with the ScreenshotMAX API via `net/http`. Below are examples for simple and signed screenshot requests.

### Basic GET Screenshot

```go theme={null}
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
)

func main() {
    endpoint := "https://api.screenshotmax.com/v1/screenshot"
    params := url.Values{}
    params.Add("access_key", "YOUR_ACCESS_KEY")
    params.Add("url", "https://example.com")
    params.Add("format", "png")

    fullURL := endpoint + "?" + params.Encode()

    resp, err := http.Get(fullURL)
    if err != nil {
        fmt.Println("Request failed:", err)
        return
    }
    defer resp.Body.Close()

    out, err := os.Create("screenshot.png")
    if err != nil {
        fmt.Println("File error:", err)
        return
    }
    defer out.Close()

    io.Copy(out, resp.Body)
    fmt.Println("Image saved to screenshot.png")
}
```

***

### HMAC-Signed GET Screenshot

```go theme={null}
package main

import (
    "crypto/hmac"
    "crypto/sha256"
    "encoding/hex"
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
)

func main() {
    accessKey := "YOUR_ACCESS_KEY"
    secretKey := "YOUR_SECRET_KEY"

    baseURL := "https://api.screenshotmax.com/v1/screenshot"

    query := url.Values{}
    query.Set("access_key", accessKey)
    query.Set("url", "https://example.com")
    query.Set("format", "png")

    qs := query.Encode()
    signature := signHMAC(qs, secretKey)

    // Add signature to query
    query.Set("signature", signature)

    fullURL := baseURL + "?" + query.Encode()

    resp, err := http.Get(fullURL)
    if err != nil {
        fmt.Println("Request failed:", err)
        return
    }
    defer resp.Body.Close()

    out, _ := os.Create("screenshot.png")
    io.Copy(out, resp.Body)
    fmt.Println("Image saved to screenshot.png")
}

func signHMAC(message, secret string) string {
    mac := hmac.New(sha256.New, []byte(secret))
    mac.Write([]byte(message))
    return hex.EncodeToString(mac.Sum(nil))
}
```

***

## Next Steps

* Explore other API options like HTML to PDF, animated screenshots, or web scraping.
* Create scheduled recurring screenshots via [**Scheduled Tasks API**](/guides/start/scheduled-tasks)

## Support

For questions, issues, or feature requests, please contact our support team at [support@screenshotmax.com](mailto:support@screenshotmax.com).
