INTEGRATIONS / HTTP RECIPE

take it, meet Go.

The generated Go example sets a bounded timeout, sends JSON and fails loudly on non-2xx responses.

← All integrations

Your first connection.

  1. 01

    Use Go 1.20 or newer and keep TAKEIT_API_KEY in the server environment.

  2. 02

    Set TAKEIT_BASE_URL to your take it origin without a trailing slash.

  3. 03

    Copy the Go example below, run gofmt, then inspect the request ID and response before adding a larger batch.

Build the request.

Set the environment variables in your terminal for these code examples. In automation tools, enter the URL and credentials in the tool’s own fields.

package main

import (
  "bytes"
  "fmt"
  "io"
  "net/http"
  "os"
  "time"
)

func main() {
  request, err := http.NewRequest("POST", os.Getenv("TAKEIT_BASE_URL")+"/api/takeit/v1/scrape", bytes.NewBufferString("{\n  \"url\": \"https://example.com\"\n}"))
  if err != nil { panic(err) }
  request.Header.Set("Authorization", "Bearer "+os.Getenv("TAKEIT_API_KEY"))
  request.Header.Set("Content-Type", "application/json")
  response, err := (&http.Client{Timeout: 45 * time.Second}).Do(request)
  if err != nil { panic(err) }; defer response.Body.Close()
  body, _ := io.ReadAll(response.Body)
  if response.StatusCode < 200 || response.StatusCode >= 300 { panic(fmt.Sprintf("take it HTTP %s: %s", response.Status, body)) }
  fmt.Println(string(body))
}

This edits a code example. It does not send a request or use credits.

Run a request in your workspace
YOUR PRIVACY

Choose what works for you. You can reopen these settings from the footer at any time.