Package: kuantaz-api-client
KzCaptcha - Python API ClientThis library offers the API client to communicate with kuantaz to verify a submission.DescriptionThis Python library lets you connect to a kuantaz installation and verify the submitted data.InstallationInstall using pipInstall this library by using pip:pip install kuantaz-api-clientUsageCreate a project in your kuantaz installationInclude the kuantaz script in your form<divid="kuantaz-box"></div><scriptsrc="https://[URL]/build/kuantaz-frontend.js"defer></script><script>varkz;window.onload=function(){kz=newkzCaptcha("kuantaz-box","https://[URL]","[UUID]","[PUBLIC_KEY]");};</script>Include the library in your projectpip install kuantaz-api-clientAfter the form is submitted, verify the data before processing itfromkuantaz_api_clientimportClientapi_client=Client(host,public_key,private_key)your_post_data={}# This needs to be filled with the post datakuantaz_submit_token=your_post_data['_kuantaz_submitToken']kuantaz_validation_token=your_post_data['_kuantaz_validationToken']result=api_client.verify_submission(your_post_data,kuantaz_submit_token,kuantaz_validation_token)ifresult.is_submittable():# Send the email or process the datapasselse:# Show error messagepassAPI DocumentationClientClient initializationCreate a new client object to use the API client.fromkuantaz_api_clientimportClientapi_client=Client(host,public_key,private_key,verify_ssl)ParameterTypeDescriptionhoststrThe host of the kuantaz installationpublic_keystrThe public key of the kuantaz projectprivate_keystrThe private key of the kuantaz projectverify_sslboolSet to False if the SSL certificate should not be verified.Verify form dataTo verify the form data, callverify_submissionwith the form data in an array and the submit and validation tokens, which kuantaz generated on the form initialization and the form data validation. The method will return aVerificationResultobject.result=api_client.verify_submission(form_data,kuantaz_submit_token,kuantaz_validation_token)ParameterTypeDescriptionform_datadictThe dictionary with all the submitted form data.kuantaz_submit_tokenstrThe submit token which was generated by kuantaz and submitted with the form datakuantaz_validation_tokenstrThe validation token which kuantaz generated after the validation and which was submitted with the form dataVerificationResultConstantsFIELD_NOT_VERIFIED: 'not-verified'FIELD_VALID: 'valid'FIELD_INVALID: 'invalid'is_submittable(): boolReturnsTrueif the form is submittable. This means that the verification was successful and the
form data are valid.is_valid(): boolReturnsTrueif kuantaz determined the form as valid. The difference tois_submittable()is, that this
is the original result from kuantaz, whileis_submittable()also checks if the verification was done correctly.get_verified_fields(): list (seeConstants)Returns an array with all verified field keys.get_verified_field(key): string (seeConstants)Returns the verification status of one field.has_issues(): boolReturnsTrueif there were verification issues.get_issues(): listReturns an array with all verification issues.Get the statistic data by dateTo get the statistic data grouped by date, callget_statistic_by_date. The method accepts a time range in seconds for which the data should be returned (last x seconds). The method will return aStatisticResultobject.result=api_client.get_statistic_by_date(range)ParameterTypeDescriptionrangeintThe time range in seconds for which the statistic should be returned (last X seconds)StatisticResultget_number_of_valid_submissions(): intReturn the number of valid submissions in the requested time range.get_number_of_spam_submissions(): intReturn the number of spam submissions in the requested time range.get_numbers_by_date(): dictReturn the numbers grouped by date.