Solve hCaptcha in Go

Go does not need a client library. POST the solve, block with wait=90, and decode the token from the JSON body.

Steps

  1. Build the JSON body with type, sitekey, and url.
  2. Send it to /v1/solves?wait=90 with a Bearer key. Give the HTTP client longer than the wait.
  3. Decode token and submit it as h-captcha-response.
go
package main

import (
  "bytes"
  "encoding/json"
  "net/http"
  "os"
  "time"
)

func main() {
  body, _ := json.Marshal(map[string]string{
    "type": "hcaptcha",
    "sitekey": "10000000-ffff-ffff-ffff-000000000001",
    "url": "https://example.com/login",
  })
  req, _ := http.NewRequest("POST", "https://api.vanishcaptcha.com/v1/solves?wait=90", bytes.NewReader(body))
  req.Header.Set("Authorization", "Bearer "+os.Getenv("VANISHCAPTCHA_KEY"))
  req.Header.Set("Content-Type", "application/json")
  res, err := (&http.Client{Timeout: 120 * time.Second}).Do(req)
  if err != nil { panic(err) }
  defer res.Body.Close()
  var out struct{ Token string `json:"token"` }
  json.NewDecoder(res.Body).Decode(&out)
}

Enterprise rqdata

If the widget carries rqdata, send type: "hcaptcha_enterprise" and that value. The token that comes back is what the enterprise sitekey expects. Fields are in the API reference.

Questions

Does this solve reCAPTCHA or Turnstile?
No. These guides are hCaptcha only. reCAPTCHA and Turnstile are not live on VanishCaptcha.
How long is the token good for?
About two minutes, and it can be submitted once. Request it immediately before the form goes out.

Start solving hCaptcha in minutes.

1,400 free credits on signup. Pay per solve, credits never expire, failed solves never charged.