Python

The following tutorial will show you how to integrate Trustcaptcha into Python.

Preparation

The following preparations should be made before you start implementing Trustcaptcha in your Python backend.

Requirements

  • An account with Trustcaptcha and an existing CAPTCHA.
  • A backend with Python , into which Trustcaptcha is to be integrated.

Knowledge (recommended)

  • Basic knowledge in Python.
  • Understanding of the basic functionality of Trustcaptcha as well as the backend process.

Add Dependency

To use the Trustcaptcha library, you must first insert the corresponding dependencies into your project.

Pip

Install the Trustcaptcha library using Pip.

Use Library

Below you will find out how you can use the library.

Fetch Result

You can retrieve the verification result using the get_verification_result() method of the CaptchaManager class from our servers. For this, you must provide your secret-keyue and the verification token.

Use Result

Once you have successfully retrieved the verification result, you can plan your next steps based on it. A concrete overview of all the information contained in the verification result and their respective meanings can be found in The Backend.

Example with Flask

The following example shows a possible implementation with the Flask library. With a POST request to /api/example, the verification token is transmitted within the request body. Subsequently, the result is retrieved from the server. If the verification has not been passed or the bot score is above 0.5, a warning will be given as an example. Finally, the entire result is returned to the client.
The entire example including source code can be found on Github.