Skip to main content

The official wrapper for the Onfido API

Project description

Onfido Python Client Library

onfido-python on PyPI

The official wrapper for Onfido's API. Refer to the full API documentation for details of expected requests and responses for all resources.

PyPI version

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

This project supersedes the automatically generated api-python-client library (onfido in PyPI).

Installation

pip install onfido-python

:warning: Having the old onfido package installed at the same time will cause errors.

Getting started

Make API calls by using an instance of the Api class and providing your API token:

import onfido

api = onfido.Api("<YOUR_API_TOKEN>")

Regions

Set the region in the API instance using the region parameter, which takes a value from the Region enum (currently Region.EU, Region.US or Region.CA).

For example, to specify the EU region:

import onfido
from onfido.regions import Region

api = onfido.Api("<YOUR_API_TOKEN>", region=Region.EU)

region does not take a default parameter. Failure to pass a correct region will raise an OnfidoRegionError.

See https://documentation.onfido.com/#regions for more information about our supported regions at a given time.

Timeouts

You can optionally set a global timeout for all requests in the API constructor. This takes a floating number input and each whole integer increment corresponds to a second.

For example, to set a timeout of 1 second:

api = onfido.Api("<YOUR_API_TOKEN>", timeout=1)

The default value for timeout is None, meaning no timeout will be set on the client side.

Response format

The Python library will return JSON requests directly from the API. Each request corresponds to a resource.

All resources share the same interface when making API calls. For example, use .create to create a resource, .find to find one, and .all to fetch all resources.

For example, to create an applicant:

applicant_details = {
  'first_name': 'Jane',
  'last_name': 'Doe',
  'dob': '1984-01-01',
  'address': {
    'street': 'Second Street',
    'town': 'London',
    'postcode': 'S2 2DF',
    'country': 'GBR'
  },
  'location': {
    'ip_address': '127.0.0.1',
    'country_of_residence': 'GBR'
  }
}

api.applicant.create(applicant_details)
{
  'id': '<APPLICANT_ID>',
  'created_at': '2019-10-09T16:52:42Z',
  'sandbox': True,
  'first_name': 'Jane',
  'last_name': 'Doe',
  'email': None,
  'dob': '1990-01-01',
  'delete_at': None,
  'href': '/v3.1/applicants/<APPLICANT_ID>',
  'id_numbers': [],
  'address': {
    'flat_number': None,
    'building_number': None,
    'building_name': None,
    'street': 'Second Street',
    'sub_street': None,
    'town': 'London',
    'state': None,
    'postcode': 'S2 2DF',
    'country': 'GBR',
    'line1': None,
    'line2': None,
    'line3': None
  },
  'phone_number': None,
  'location': {
    'ip_address': '127.0.0.1',
    'country_of_residence': 'GBR'
  }
}

See https://documentation.onfido.com/#request,-response-format for more information.

Resources

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

Error Handling

  • OnfidoServerError is raised whenever Onfido returns a 5xx response
  • OnfidoRequestError is raised whenever Onfido returns a 4xx response
  • OnfidoInvalidSignatureError is raised whenever a signature from the header is not equal to the expected signature you compute for it
  • OnfidoTimeoutError is raised if a timeout occurs
  • OnfidoConnectionError is raised whenever any other network error occurs
  • OnfidoUnknownError is raised whenever something unexpected happens

Contributing

  1. Fork it ( https://github.com/onfido/onfido-python/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Run the tests (poetry run pytest tests/test_my_new_feature.py)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Support

Should you encounter any technical issues during integration, please contact Onfido’s Customer Support team via email, including the word ISSUE: at the start of the subject line.

Alternatively, you can search the support documentation available via the customer experience portal, public.support.onfido.com.

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-2.10.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

onfido_python-2.10.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: onfido_python-2.10.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for onfido_python-2.10.0.tar.gz
Algorithm Hash digest
SHA256 a7c24125b9da60556bc038ca9f7e398880a005ffb851fa64da74bbc599950d56
MD5 57d05f5a8c870ed145dfe36819046621
BLAKE2b-256 5a5a273d2d040b6eecfcc6d5d337a0832e30d22c4cb5cc372b4894392d3ea729

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onfido_python-2.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d06d92464a7cdaaeb4229da8ee859b6e9e047628369fca8d1badfdd724933330
MD5 bcb6641ced2b6cef5bd367f274b7d06c
BLAKE2b-256 81089f3f02ccadcc74bfa6292e2a29aad3bc86c59769c1a488652c426c74ab91

See more details on using hashes here.

Supported by

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