.....
.....
# Get the risk score and the reason(s)forreasoninresponse.risk_analysis.reasons:
print(reason)
print("The reCAPTCHA score for this token is: "+str(response.risk_analysis.score))
....
....
v1beta1
.....
.....
# Get the risk score and the reason(s)forreasoninresponse.reasons:
print(reason)
print("The reCAPTCHA score for this token is: "+str(response.score))
....
....
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-17。"],[],[],null,["# Migrate to the v1 API\n\nThis document shows you how to migrate from the `v1beta1` version to the `v1`\nversion of the reCAPTCHA Enterprise API.\n| **Caution:** On August 31st, 2025, the `v1beta1` version of the reCAPTCHA Enterprise API will be deprecated. To avoid any disruption to your service, migrate to the `v1` version of the reCAPTCHA Enterprise API before August 31st, 2025.\n\nTo migrate your assessment calls from `v1beta1` to `v1`, do the following:\n\n1. Replace calls to create assessments.\n\n Replace `https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments?key=API_KEY`\n with `https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments?key=API_KEY`\n | **Note:** You can use the same API key.\n2. Understand the changes in the assessment's JSON response:\n\n When you use `v1`, the `reasons` and `score` fields are encapsulated in\n `riskAnalysis` in the response, and when you use `v1beta1`, the`reasons` and\n `score` fields are not encapsulated in the response. \n\n ### v1\n\n\n ```bash\n {\n \"event\":{\n \"expectedAction\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eEXPECTED_ACTION\u003c/var\u003e\",\n \"hashedAccountId\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e\",\n \"siteKey\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eKEY_ID\u003c/var\u003e\",\n \"token\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eTOKEN\u003c/var\u003e\",\n \"userAgent\":\"(USER-PROVIDED STRING)\",\n \"userIpAddress\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eUSER_PROVIDED_IP_ADDRESS\u003c/var\u003e\"\n },\n \"name\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eASSESSMENT_ID\u003c/var\u003e\",\n \"riskAnalysis\":{\n \"reasons\":[],\n \"score\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eSCORE\u003c/var\u003e\n },\n \"tokenProperties\":{\n \"action\":\"USER_INTERACTION\",\n \"createTime\":\"TIMESTAMP\",\n \"hostname\":\"HOSTNAME\",\n \"invalidReason\":\"(ENUM)\",\n \"valid\":(BOOLEAN)\n }\n }\n ```\n\n \u003cbr /\u003e\n\n ### v1beta1\n\n\n ```bash\n {\n \"event\":{\n \"expectedAction\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eEXPECTED_ACTION\u003c/var\u003e\",\n \"hashedAccountId\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e\",\n \"siteKey\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eKEY_ID\u003c/var\u003e\",\n \"token\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eTOKEN\u003c/var\u003e\",\n \"userAgent\":\"(USER-PROVIDED STRING)\",\n \"userIpAddress\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eUSER_PROVIDED_IP_ADDRESS\u003c/var\u003e\"\n },\n \"name\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eASSESSMENT_ID\u003c/var\u003e\",\n \"reasons\":[],\n \"score\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eSCORE\u003c/var\u003e\",\n\n \"tokenProperties\":{\n \"action\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eUSER_INTERACTION\u003c/var\u003e\",\n \"createTime\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eTIMESTAMP\u003c/var\u003e\",\n \"hostname\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eHOSTNAME\u003c/var\u003e\",\n \"invalidReason\":\"(ENUM)\",\n \"valid\":(BOOLEAN)\n }\n }\n ```\n\n \u003cbr /\u003e\n\n3. Update your environment to use the `reasons` and `score` fields from the JSON response for\n `v1`.\n\n The following sample code shows the fields that are used from the response of `v1`\n and `v1beta1`: \n\n ### v1\n\n ```bash\n .....\n .....\n # Get the risk score and the reason(s)\n for reason in response.risk_analysis.reasons:\n print(reason)\n print(\n \"The reCAPTCHA score for this token is: \"\n + str(response.risk_analysis.score)\n )\n ....\n ....\n ```\n\n ### v1beta1\n\n ```bash\n .....\n .....\n # Get the risk score and the reason(s)\n for reason in response.reasons:\n print(reason)\n print(\n \"The reCAPTCHA score for this token is: \"\n + str(response.score)\n )\n ....\n ....\n ```\n4. Replace calls to annotate assessments.\n\n Replace `https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments}:annotate`\n with `https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments}:annotate`\n5. If you are currently logging your `create` and `annotate` API calls using\n [audit logging](/recaptcha/docs/audit-logging) it is\n recommended to use\n [platform logging](/recaptcha/docs/platform-logging)\n (available for `v1` only).\n\nWhat's next\n-----------\n\n- [Create an assessment](/recaptcha/docs/create-assessment)\n- [Annotate an assessment](/recaptcha/docs/annotate-assessment)"]]