Skip to main content

KgCaptcha SDK

凯格验证码服务 Python SDK,支持行为验证和验证码校验。

安装

pip install kgcaptcha

快速开始

from kgcaptcha import KgCaptcha

# 初始化
captcha = KgCaptcha(appid="你的公钥", secret="你的秘钥")

# 设置参数
captcha.clientIp = "192.168.1.1"  # 客户端IP
captcha.domain = "https://example.com"  # 授权域名
captcha.token = "前端返回的token"  # 前端验证成功后获取的token

# 发送验证请求
result = captcha.sendRequest()

# 处理结果
if result.code == 0:
    print("验证通过")
else:
    print(f"验证失败: {result.msg}")

API 文档

KgCaptcha 类

初始化

captcha = KgCaptcha(appid, secret)
参数 类型 说明
appid str 公钥,从 KgCaptcha 控制台获取
secret str 秘钥,从 KgCaptcha 控制台获取

属性

属性 类型 说明
clientIp str 客户端IP地址
clientBrowser str 浏览器信息
userId str 用户ID
domain str 授权域名
token str 前端验证token
connectTimeout int 连接超时时间(秒),默认50
appCdn str CDN地址,默认 https://cdn.kgcaptcha.com

方法

sendRequest() - 发送验证请求

result = captcha.sendRequest()

返回结果:

  • result.code: 状态码,0表示成功
  • result.msg: 提示信息

parse(environ) - 解析WSGI环境变量

data = captcha.parse(environ)

适用于WSGI服务器,自动提取IP、浏览器、GET/POST参数等。

许可证

MIT License

Metadata

Release files for kgcaptcha 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kgcaptcha 1.0.0
File Size Uploaded Provenance
kgcaptcha-1.0.0.tar.gz 5.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kgcaptcha 1.0.0
File Interpreter ABI Platform
kgcaptcha-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / kgcaptcha-1.0.0.tar.gz

Download URL kgcaptcha-1.0.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2bf49e6db8994ecbffc7101b3ba68fb53a8c464b8444dfcc26688deac616aa21
BLAKE2b-256 checksum
How to use checksums
8b8b2623c6bd9a4c8fdfc4476b1b69ca2bed8f1438641ff44e2f9fdfa48e0a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.5

Release files / kgcaptcha-1.0.0-py3-none-any.whl

Download URL kgcaptcha-1.0.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2ceed3c95610af71a4da26e35efc9a2430116260c8efcb605122e6a79fd506e
BLAKE2b-256 checksum
How to use checksums
eb210ad4e902cc524161377d056d38cafb2da797850c9b706c31152f3ce290a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.5

Security for kgcaptcha 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page