Skip to main content

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-client

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: FriendlyCaptchaResult = 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 passing strict=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

friendly_captcha_client-0.0.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

friendly_captcha_client-0.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file friendly_captcha_client-0.0.2.tar.gz.

File metadata

File hashes

Hashes for friendly_captcha_client-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4f635916a2d519924b590667c08ef4bcbfc8f76dae6597b82493cccfd881259e
MD5 47e166f313c7e16ffe28b10fd3f994f9
BLAKE2b-256 8d7286b6586427ae7ea6b1b2aadcfd72745afee636de69fe39630928ce6c46df

See more details on using hashes here.

File details

Details for the file friendly_captcha_client-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for friendly_captcha_client-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4680aa1327e0a091bc866d603672d275b8a27e1255b1df0587498b67d8b7148f
MD5 4255bdaa2b9795727ac79f0dae619893
BLAKE2b-256 3a69ef7669e2a03379666bcab7ab46942321461d098095d2f98f748ee11f5c12

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page