Go Integration

Go integrations should use the exact endpoint shown in the portal. That keeps examples accurate for account-specific ports and static IP assignments.

Use the exact endpoint shown in Portal → Proxy IPs or Rotating Gateway IPs. Public docs intentionally use placeholders like <HTTP_ENDPOINT> because live host/port values are account-specific.

net/http via HTTP proxy

package main

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

func main() {
  proxyURL, _ := url.Parse("http://<USERNAME>:<API_KEY>@<HTTP_ENDPOINT>")
  client := &http.Client{
    Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
  }

  resp, err := client.Get("https://ip.ninjasproxy.com/")
  if err != nil {
    panic(err)
  }
  defer resp.Body.Close()

  body, _ := io.ReadAll(resp.Body)
  fmt.Println(string(body))
}

SOCKS5

package main

import (
  "fmt"
  "io"
  "net"
  "net/http"

  "golang.org/x/net/proxy"
)

func main() {
  auth := &proxy.Auth{User: "<USERNAME>", Password: "<API_KEY>"}
  dialer, err := proxy.SOCKS5("tcp", "<SOCKS_ENDPOINT>", auth, proxy.Direct)
  if err != nil {
    panic(err)
  }

  transport := &http.Transport{}
  transport.Dial = dialer.Dial
  client := &http.Client{Transport: transport}

  resp, err := client.Get("https://ip.ninjasproxy.com/")
  if err != nil {
    panic(err)
  }
  defer resp.Body.Close()

  body, _ := io.ReadAll(resp.Body)
  fmt.Println(string(body))
  _ = net.IP{}
}

Rotating gateway

package main

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

func main() {
  proxyURL, _ := url.Parse("http://<USERNAME>:<API_KEY>@<ROTATING_HTTP_ENDPOINT>")
  client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}

  req, _ := http.NewRequest("GET", "https://ip.ninjasproxy.com/", nil)
  req.Header.Set("X-Session-ID", "checkout-flow-42")
  req.Header.Set("X-Target-Geo", "US")

  resp, err := client.Do(req)
  if err != nil {
    panic(err)
  }
  defer resp.Body.Close()

  fmt.Println(resp.Status)
}

Next Steps

Use these docs with AI

Start with the AI guide or hand llms.txt to your assistant.
Use with AI
llms.txt