Fingerprint Pro Server Python SDK
Fingerprint is a device intelligence platform offering 99.5% accurate visitor identification.
The Fingerprint Server Python SDK is an easy way to interact with the Fingerprint Server API from your Python application. You can retrieve visitor history or individual identification events.
This Python package is automatically generated by the Swagger Codegen project:
- API version: 3
- Package version: 8.1.0
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen
Requirements
The following Python versions are supported:
Installation & Usage
pip install
You can install the package directly from the Github
pip install git+https://github.com/fingerprintjs/fingerprint-pro-server-api-python-sdk.git
Or from the PyPI
pip install fingerprint_pro_server_api_sdk
Then import the package:
import fingerprint_pro_server_api_sdk
Setuptools
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install
to install the package for all users)
Then import the package:
import fingerprint_pro_server_api_sdk
Getting Started
Please follow the installation procedure and then run the following:
import fingerprint_pro_server_api_sdk
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
Examples
Fetching visits using visitorId:
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
visitor_id = 'visitor_id_example'
limit = 10
try:
api_response = api_instance.get_visits(visitor_id, limit=2)
print(api_response)
except KnownApiException as e:
structured_error = e.structured_error
print("Error: %s\n" % structured_error.error)
except ApiException as e:
print("Exception when calling FingerprintApi->visitors_visitor_id_get: %s\n" % e)
Delete visits using visitorId:
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
visitor_id = 'visitor_id_example'
try:
api_instance.delete_visitor_data(visitor_id)
except KnownApiException as e:
structured_error = e.structured_error
print("Error: %s\n" % structured_error.error)
except ApiException as e:
print("Exception when calling FingerprintApi->delete_visitor_data: %s\n" % e)
Fetching events for requestId:
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
request_id = 'request_id_example'
try:
events_response = api_instance.get_event(request_id)
except KnownApiException as e:
structured_error = e.structured_error
print("Error code: %s. Error message: %s\n" % (structured_error.error.code, structured_error.error.message))
except ApiException as e:
print("Exception when calling FingerprintApi->get_event: %s\n" % e)
Update event for requestId:
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk import EventsUpdateRequest
from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
request_id = 'request_id_example'
body = EventsUpdateRequest(linked_id='foo')
try:
api_instance.update_event(body, request_id)
except KnownApiException as e:
structured_error = e.structured_error
print("Error code: %s. Error message: %s\n" % (structured_error.error.code, structured_error.error.message))
except ApiException as e:
print("Exception when calling FingerprintApi->update_event: %s\n" % e)
Sealed results
This SDK provides utility methods for decoding sealed results.
import base64
import os
from dotenv import load_dotenv
from fingerprint_pro_server_api_sdk import unseal_event_response, DecryptionKey, DecryptionAlgorithm
load_dotenv()
sealed_result = base64.b64decode(os.environ["BASE64_SEALED_RESULT"])
key = base64.b64decode(os.environ["BASE64_KEY"])
try:
event_response = unseal_event_response(sealed_result, [DecryptionKey(key, DecryptionAlgorithm['Aes256Gcm'])])
print("\n\n\nEvent response: \n", event_response.products)
except Exception as e:
print("Exception when calling unsealing events response: %s\n" % e)
exit(1)
print("Unseal successful!")
exit(0)
To learn more, refer to example located in sealed_results_example.py.
Webhook signature validation
This SDK provides utility method for verifying the HMAC signature of the incoming webhook request.
import os
from flask import Flask, request, jsonify
from fingerprint_pro_server_api_sdk import WebhookValidation
app = Flask(__name__)
@app.route('/api/webhook', methods=['POST'])
def webhook_handler():
try:
secret = os.getenv("WEBHOOK_SIGNATURE_SECRET")
if not secret:
return jsonify({"message": "Secret key is not configured."}), 400
header = request.headers.get('fpjs-event-signature')
if not header:
return jsonify({"message": "Missing fpjs-event-signature header."}), 400
data = request.get_data()
is_valid = WebhookValidation.is_valid_webhook_signature(header, data, secret)
if not is_valid:
return jsonify({"message": "Webhook signature is invalid."}), 403
return jsonify({"message": "Webhook received."}), 200
except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
To learn more, refer to example located in webhook_signature_example.py.
Documentation for API Endpoints
All URIs are relative to https://api.fpjs.io
Class | Method | HTTP request | Description |
---|
FingerprintApi | delete_visitor_data | DELETE /visitors/{visitor_id} | Delete data by visitor ID |
FingerprintApi | get_event | GET /events/{request_id} | Get event by request ID |
FingerprintApi | get_visits | GET /visitors/{visitor_id} | Get visits by visitor ID |
FingerprintApi | update_event | PUT /events/{request_id} | Update an event with a given request ID |
Documentation For Models
Documentation For Authorization
- Type: API key
- API key parameter name: Auth-API-Key
- Location: HTTP header
ApiKeyQuery
- Type: API key
- API key parameter name: api_key
- Location: URL query string
Documentation for sealed results
Support
To report problems, ask questions or provide feedback, please use Issues.
If you need private support, you can email us at oss-support@fingerprint.com.
License
This project is licensed under the MIT License.