Skip to content
On this page

ReCaptchaV3 协议接口

⚠️ 通过 createTask 创建任务, 然后通过 getTaskResult 获取识别结果

任务类型type如下

  • ReCaptchaV3Task 必须传入代理
  • ReCaptchaV3EnterpriseTask 必须传入代理
  • ReCaptchaV3TaskProxyLess 无需代理或已内置代理
  • ReCaptchaV3EnterpriseTaskProxyLess 无需代理或已内置代理

推荐使ReCaptchaV3M1Task 通常ReCaptchaV3需要较好的代理,例如ipv6,动态变化住宅ipv4代理, M1Task一般能得到更高的分数(0.7以上).

创建任务

通过 createTask 创建任务

在创建任务前,你可以学习下面的内容

参数结构

属性类型Required说明
typeStringYesReCaptchaV3Task
ReCaptchaV3TaskProxyLess
ReCaptchaV3EnterpriseTask
ReCaptchaV3EnterpriseTaskProxyLess
websiteURLStringYesreCaptcha 网页地址,一般固定值。
websiteKeyStringYesreCaptcha 网站密钥,固定值。
pageActionStringYesWidget action value. Website owner defines what user is doing on the page through this parameter. Default value: verify Example: grecaptcha.execute('site_key', {action:'login_test'}).
minScoreDoubleNoValue from 0.1 to 0.9.
proxyStringNo学习如何使用代理
enterprisePayloadObjectNoenterprise payload
apiDomainStringNoDomain address from which to load reCAPTCHA Enterprise.
For example:
http://www.google.com/
http://www.recaptcha.net/
Don't use a parameter if you don't know why it's needed.
userAgentStringNoBrowser's User-Agent which is used in emulation. It is required that you use a signature of a modern browser, otherwise Google will ask you to "update your browser".
cookiesArrayNo学习如何使用cookies

请求示例

json
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
json
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "ReCaptchaV3Task",
    "websiteURL": "https://www.google.com/recaptcha/api2/demo",
    "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
    "pageAction": "login",
    "minScore": 0.7,
    //This parameter is optional        
    "enterprisePayload": {
      //This parameter is optional
      "s": "SOME_ADDITIONAL_TOKEN"
    },
    //This parameter is optional
    "apiDomain": "",
    //This parameter is optional
    "userAgent": "",
    "cookies": [
      {
        "name": "__Secure-3PSID",
        "value": "AIKkIs3ch7YsxxxxYIzRqNZPGm60cdHozgwfUW1o8MF3kRcf8clJscTI6OtCqVpqNF8I88pLBJkUgQ"
      },
      {
        "name": "__Secure-3PAPISID",
        "value": "TKS1iVpGxYbxxxk0n2o/AytXQTb6RUALqxSEL"
      }
    ],
    //This parameter is optional
    "proxy": "http:ip:port:user:pass" // socks5:ip:port:user:pass
  }
}

响应示例

json
{
    "errorId": 0,
    "errorCode": "",
    "errorDescription": "",
    "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006" // 请记录此ID
}

获取结果

使用 getTaskResult 方法获取识别结果

根据系统负载,您将在 1s20s 的时间间隔内得到结果

请求示例

json
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json

{
    "clientKey": "YOUR_API_KEY",
    "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}

响应示例

json
{
    "errorId": 0,
    "errorCode": null,
    "errorDescription": null,
    "solution": {
        "userAgent": "xxx", //userAgent
        "expireTime": 1671615324290, //过期时间
        "gRecaptchaResponse": "3AHJ....." //响应token
    },
    "status": "ready"
}

使用 SDK 请求

python
#pip install --upgrade capsolver
#export CAPSOLVER_API_KEY='...'

import capsolver
# capsolver.api_key = "..."
solution = capsolver.solve({
            "type": "ReCaptchaV3TaskProxyLess",
            "websiteURL": "https://www.google.com/recaptcha/api2/demo",
            "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_kl-",             ...
           })
golang
package main

import (
	"fmt"
	capsolver_go "github.com/capsolver/capsolver-go"
	"log"
)

func main() {
	// first you need to install sdk
	//go get github.com/capsolver/capsolver-go
	//export CAPSOLVER_API_KEY='...' or
	//capSolver := CapSolver{apiKey:"..."}

	capSolver := capsolver_go.CapSolver{}
	solution, err := capSolver.Solve(map[string]any{
		"type":       "ReCaptchaV3TaskProxyLess",
		"websiteURL": "https://www.google.com/recaptcha/api2/demo",
		"websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_kl-",
	})
	if err != nil {
		log.Fatal(err)
		return
	}
	fmt.Println(solution)
}