Home / Cost tools / cURL converter / Go
cURL to Go converter
Paste a cURL command and get the same request in Go, using net/http. It converts in your browser; nothing you paste is sent anywhere.
Converted in your browser. Nothing you paste is stored or sent, so a command with your API key in it stays on your machine.
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
client := &http.Client{CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}
req, err := http.NewRequest("GET", "https://api.scraper.example/v1/scrape?url=https%3A%2F%2Fshop.example.com%2Fproducts%3Fpage%3D2&render_js=true&country=us", nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode)
fmt.Println(string(out))
} Running the code
Save it as main.go and run go run main.go; net/http is in the standard library. The body, when there is one, is passed as a reader.
Where net/http differs from curl
Go's http.Client follows up to ten redirects by default, so without -L the code stops it with CheckRedirect. It has no timeout unless you set one on the client, as the code does when the command has --max-time.
What calls like this one cost
The example is a scraping API call with JavaScript rendering on and a country chosen. 100,000 of them a month cost from $49.00 on ScrapeBadger, and the same pages without rendering from $14.99 on FlyByAPIs AI Web Scraper, the cheapest complete bills across 32 web scraping APIs this site prices from their own pages. What rendering adds on each API