--- title: "Quickstart: Go" slug: "quickstart-go" updated: 2026-09-10T17:38:57Z published: 2026-09-10T17:38:57Z canonical: "docs.redcanary.com/quickstart-go" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.redcanary.com/llms.txt > Use this file to discover all available pages before exploring further. # Go Example Follow these necessary steps to write and run a simple Go program that queries the Zscaler MDR API. ## Prerequisites Before running any code, ensure you have the following: - [Your API token](/doc/docs/red-canary-rest-api#generating-an-api-authentication-token) - [The latest recommended version of Go](https://go.dev) ## Create your Go program Create a Go program called `example.go`, which fetches a list of endpoints from a subdomain. 1. In your working directory, create a new file called `example.go`, and then copy the following code into it. ```plaintext package main import (    "fmt"    "io/ioutil"    "log"    "net/http"    "time" ) func main() {    // Create a client with a 3 second timeout.    client := &http.Client{        Timeout: 3 * time.Second,    }    // Create a GET request.    request, err := http.NewRequest("GET", "https://.my.redcanary.co/openapi/v3/endpoints", nil)    if err != nil {        log.Fatalf("Something went wrong: %s", err.Error())    }    // Add the API key to the request.    request.Header.Set("X-Api-Key", "")    // Send the request and receive a response.    response, err := client.Do(request)    if err != nil {        log.Fatalf("Something went wrong: %s", err.Error())    }    // Parse and print the response.    body, err := ioutil.ReadAll(response.Body)    if err != nil {        log.Fatalf("Something went wrong: %s", err.Error())    }    fmt.Println(string(body)) } ``` 2. In `example.go`, replace with the subdomain you want to query. 3. In `example.go`, replace with your API key. 4. Save `example.go`. ## Build and run the example Run your example with the following command. ```plaintext go run example.go ``` The program should print a JSON object containing the first page of endpoints associated with the subdomain. ## Customize your request with parameters You can use HTTP parameters to customize the results of your request. Visit the [Zscaler MDR API docs](https://go.my.redcanary.co/openapi/v3/docs/index.html) for a list of supported parameters for each API endpoint. ## Example: Limit the number of endpoints returned Limit the number of endpoints returned by `example.go` using the `per_page` parameter. 1. Open `example.go`, and then find the URL passed to `http.NewRequest()`. 2. Add the following to the end of the URL: ```plaintext ?per_page=1 ``` This sets the number of requested endpoints to one. 3. Save `example.go`, and then run the example. The program should print a JSON object containing exactly one endpoint.