capsolver_go

package module
v0.0.0-...-e4e07af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2025 License: BSD-2-Clause Imports: 8 Imported by: 1

README

Capsolver

CapSolver official go library

Supported CAPTCHA types:

  • Geetest
  • ReCaptchaV2
  • ReCaptchav3
  • Cloudflare

Installation

You don't need this source code unless you want to modify the package. If you just want to use the package, just run:

go get github.com/capsolver/capsolver-go

Usage

export CAPSOLVER_API_KEY='...'

Or set capsolver apiKey to its value:

 capSolver := CapSolver{}
 //capSolver := CapSolver{apiKey:"..."} 
 s, err := capSolver.Solve(
            map[string]any{
            "type":       "ReCaptchaV2taskProxyLess",
            "websiteURL": "https://www.google.com/recaptcha/api2/demo",
            "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
 })
 if err != nil {
    log.Fatal(err)
 }
 log.Println(s.Solution.GRecaptchaResponse)
	

 // recognition 
 b, err := os.ReadFile("queue-it.jpg")
 if err != nil {
    panic(err)
 }
 s, err := capSolver.Solve(
    map[string]any{
	"type": "ImageToTextTask",
        "module": "queueit",
        "body":   base64.StdEncoding.EncodeToString(b),
 })
 if err != nil {
    log.Fatal(err)
 }
 log.Println(s.Solution.Text)
		
  // get balance 
  b, err := capSolver.Balance()
  if err != nil {
    log.Fatal(err)
  }
  log.Println(b.Balance)

Documentation

Index

Constants

View Source
const (
	DEFAULT_API_HOST = "http://api.capsolver.com"
	STATUS_READY     = "ready"
	CREATE_TASK_URI  = "/createTask"
	GET_TASK_URI     = "/getTaskResult"
	BALANCE_URI      = "/getBalance"
	TASK_TIMEOUT     = 60
)

Variables

View Source
var (
	ApiKey  = os.Getenv("CAPSOLVER_API_KEY")
	ApiHost = os.Getenv("CAPSOLVER_API_HOST")
)

Functions

This section is empty.

Types

type CapSolver

type CapSolver struct {
	ApiKey string
}

func (*CapSolver) Balance

func (c *CapSolver) Balance() (*CapSolverResponse, error)

func (*CapSolver) Solve

func (c *CapSolver) Solve(task map[string]any) (*CapSolverResponse, error)

type CapSolverResponse

type CapSolverResponse struct {
	ErrorId          int32     `json:"errorId"`
	ErrorCode        string    `json:"errorCode"`
	ErrorDescription string    `json:"errorDescription,omitempty"`
	Status           string    `json:"status,omitempty"`
	Solution         *solution `json:"solution,omitempty"`
	TaskId           string    `json:"taskId,omitempty"`
	Balance          float32   `json:"balance,omitempty"`
	Packages         []string  `json:"packages,omitempty"`
}

type CapSolverTask

type CapSolverTask struct {
	Type       string `json:"type"`
	WebsiteURL string `json:"websiteURL,omitempty"`
	WebsiteKey string `json:"websiteKey,omitempty"`
	Proxy      string `json:"proxy,omitempty"`
	UserAgent  string `json:"userAgent,omitempty"`

	// GeeTest
	Gt                        string `json:"gt,omitempty"`
	Challenge                 string `json:"challenge,omitempty"`
	CaptchaId                 string `json:"captchaId,omitempty"`
	GeetestApiServerSubdomain string `json:"geetestApiServerSubdomain,omitempty"`

	// reCaptcha
	PageAction        string             `json:"pageAction,omitempty"`
	EnterPrisePayload *enterPrisePayload `json:"enterprisePayload,omitempty"`
	IsInvisible       bool               `json:"isInvisible,omitempty"`
	IsSession         bool               `json:"isSession,omitempty"`
	ApiDomain         string             `json:"apiDomain,omitempty"`

	// DataDome
	CaptchaUrl string `json:"captchaUrl,omitempty"`

	// AWS WAF
	AwsKey           string `json:"awsKey,omitempty"`
	AwsIv            string `json:"awsIv,omitempty"`
	AwsContext       string `json:"awsContext,omitempty"`
	AwsChallengeJS   string `json:"awsChallengeJS,omitempty"`
	AwsApiJs         string `json:"awsApiJs,omitempty"`
	AwsProblemUrl    string `json:"awsProblemUrl,omitempty"`
	AwsApiKey        string `json:"awsApiKey,omitempty"`
	AwsExistingToken string `json:"awsExistingToken,omitempty"`

	// cloudflare
	Metadata map[string]string `json:"metadata"`
	Html     string            `json:"html"`

	Image    string   `json:"image,omitempty"`
	Images   []string `json:"images,omitempty"`
	Question string   `json:"question,omitempty"`

	// ImageToTextTask
	Body   string `json:"body,omitempty"`
	Module string `json:"module,omitempty"`

	// VisionEngine
	ImageBackground string `json:"imageBackground,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL