Skip to main content

Python library for the Onfido API

Project description

Onfido Python Library

The official Python library for integrating with the Onfido API.

Documentation is available at https://documentation.onfido.com.

This version uses Onfido API v3.6. Refer to our API versioning guide for details. It explains which client library versions use which versions of the API.

PyPI version Build Status

Installation & Usage

Requirements

Python 3.9+

Installation

Pip

If the Python package is hosted on a repository, you can install it directly using:

pip install onfido-python

Then import the package:

import onfido

Poetry

poetry add onfido-python

Then import the package:

import onfido

Tests

Execute pytest to run the tests.

Getting Started

Import the DefaultApi object, this is the main object used for interfacing with the API:

import onfido

import urllib3
from os import environ

configuration = onfido.Configuration(
    api_token=environ['ONFIDO_API_TOKEN'],
    region=onfido.configuration.Region.EU,     # Supports `EU`, `US` and `CA`
    timeout=urllib3.util.Timeout(connect=60.0, read=60.0)
  )

with onfido.ApiClient(configuration) as api_client:
  onfido_api = onfido.DefaultApi(api_client)
  ...

NB: by default, timeout values are set to 30 seconds. You can change the default timeout values by setting the timeout parameter in the Configuration object, as shown in the example above.

Making a call to the API

  try:
    applicant = onfido_api.create_applicant(
        onfido.ApplicantBuilder(
          first_name= 'First',
          last_name= 'Last')
      )

    # To access the information access the desired property on the object, for example:
    applicant.first_name

    # ...

  except OpenApiException:
    # ...
    pass
  except Exception:
    # ...
    pass

Specific exception types are defined into exceptions.py.

Webhook event verification

Webhook events payload needs to be verified before it can be accessed. Verifying webhook payloads is crucial for security reasons, as it ensures that the payloads are indeed from Onfido and have not been tampered with. The library allows you to easily decode the payload and verify its signature before returning it as an object for user convenience:

  try:
    verifier = onfido.WebhookEventVerifier(os.environ["ONFIDO_WEBHOOK_SECRET_TOKEN"])

    signature = "a0...760e"

    event = verifier.read_payload('{"payload":{"r...3"}}', signature)
  except onfido.OnfidoInvalidSignatureError:
    # Invalid webhook signature
    pass

Recommendations

Do not use additional properties

Except for accessing Task object's outputs, avoid using the additional_properties dictionary to access undefined properties to prevent breaking changes when these fields appear.

Contributing

This library is automatically generated using OpenAPI Generator (version: 7.16.0); therefore, all contributions (except test files) should target the Onfido OpenAPI specification repository instead of this repository. Please follow the contribution guidelines provided in the OpenAPI specification repository.

For contributions to the tests instead, please follow the steps below:

  1. Fork the repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add detailed description of the feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Versioning policy

Versioning helps manage changes and ensures compatibility across different versions of the library.

Semantic Versioning policy is used for library versioning, following the guidelines and limitations outlined below:

  • MAJOR versions (x.0.0) may:
    • target a new API version
    • include non-backward compatible change
  • MINOR versions (0.x.0) may:
    • add a new functionality, non-mandatory parameter or property
    • deprecate an old functionality
    • include non-backward compatible change to a functionality which is:
      • labelled as alpha or beta
      • completely broken and not usable
  • PATCH version (0.0.x) will:
    • fix a bug
    • include backward compatible changes only

More documentation

Additional documentation and code examples can be found at https://documentation.onfido.com.

Support

Should you encounter any technical issues during integration, please contact Onfido's Customer Support team via the Customer Experience Portal which also includes support documentation.

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

onfido_python-6.1.0.tar.gz (155.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onfido_python-6.1.0-py3-none-any.whl (553.7 kB view details)

Uploaded Python 3

File details

Details for the file onfido_python-6.1.0.tar.gz.

File metadata

  • Download URL: onfido_python-6.1.0.tar.gz
  • Upload date:
  • Size: 155.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for onfido_python-6.1.0.tar.gz
Algorithm Hash digest
SHA256 04faa2a9fd6c7696547f673311aa5c13e18f7bb5382dd7760750bd908eb4b0be
MD5 6afe503035098f3a6d9ab40d291690bb
BLAKE2b-256 41d5a613d39a50218fbd9b7ccf236b0ed639b55a44d322a5eb9f1a90c25737a0

See more details on using hashes here.

File details

Details for the file onfido_python-6.1.0-py3-none-any.whl.

File metadata

  • Download URL: onfido_python-6.1.0-py3-none-any.whl
  • Upload date:
  • Size: 553.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for onfido_python-6.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94f8209e5102962ce2abc608d0b908ccc711943bc0bde3e41c971cd07033f964
MD5 341f621c904c167b3b1aca9b472b56d0
BLAKE2b-256 750f7f422b48a1573c3365b66f0b39be8ea6cda0e56c15a9fbd5cbcb9125ae70

See more details on using hashes here.

Supported by

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