A client for Friendly Captcha.
Project description
Friendly Captcha SDK
A Python client for the Friendly Captcha service. This client allows for easy integration and verification of captcha responses with the Friendly Captcha API.
Installation
pip install friendly-captcha-sdk
Usage
Initialization
To start using the client:
from friendly_client import FriendlyCaptchaClient
client = FriendlyCaptchaClient(
api_key="YOUR_API_KEY",
sitekey="YOUR_SITEKEY"
)
Verifying a Captcha Response
- To verify a captcha response:
result: Fpython3 -m buildriendlyCaptchaResult = client.verify_captcha_response("CAPTCHA_RESPONSE_HERE")
print(result.should_accept) # True
print(result.was_able_to_verify) # True
- Verify with bad configuration in non-strict (default) mode
client.set_siteverify_endpoint("https://incorrect.endpoint.com")
result: FriendlyCaptchaResult = client.verify_captcha_response("CAPTCHA_RESPONSE_HERE")
print(result.should_accept) # True
print(result.was_able_to_verify) # False
- Verify with bad configuration in strict (default) mode
client.strict = True
client.set_siteverify_endpoint("https://incorrect.endpoint.com")
result: FriendlyCaptchaResult = client.verify_captcha_response("CAPTCHA_RESPONSE_HERE")
print(result.should_accept) # False
print(result.was_able_to_verify) # False
Configuration
The client offers several configuration options:
- api_key: Your Friendly Captcha API key.
- sitekey: Your Friendly Captcha site key.
- strict: (Optional) In case the client was not able to verify the captcha response at all, for example if there is a network failure or a mistake in configuration, by default the
verify_captcha_response
returns True regardless. By passingstrict=true
, it will be false instead: every response needs to be strictly verified. - siteverify_endpoint: (Optional) The endpoint URL for the site verification API.
- verbose: (Optional) Default is False. Turn on basic logging.
- Error Handling: The client has built-in error handling mechanisms. In case of unexpected responses or errors from the Friendly Captcha API, the client will log the error and provide a default response.
Development
To install it locally:
pip install -e .
pip install requests_mock
Run the tests:
# Run the unit tests
python -m pytest
# Run the SDK integration tests (requires that you have the SDK test mock server running)
python -m pytest integration_tests
Contributing
Contributions are welcome! If you'd like to contribute to this project, please submit a pull request with your changes.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file friendly_captcha_client-0.0.1.tar.gz
.
File metadata
- Download URL: friendly_captcha_client-0.0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca1e6820eb2a27e08e1596c3f8cf58e409932e6b6df14f5e858ff7dea5670592 |
|
MD5 | 6d53f8a39924d9c60cc92b45f7a5ab7e |
|
BLAKE2b-256 | 84b8259a78feec1e3a3630d1105de91bfed88bb955b0da8d72026f40a7e4ab7c |
File details
Details for the file friendly_captcha_client-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: friendly_captcha_client-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c10120df74f286a2a14a80cca90323bed4dc7ea632335a22e0be79236e0d8a5e |
|
MD5 | 9ffe60018555e414e4e0fe28c5243195 |
|
BLAKE2b-256 | 66763c34177088cc367b70f1d91b2b1a82893808f876e0d0ce902e7fec7909c3 |