Skip to main content

The official wrapper for the Onfido API

Project description

Onfido Python Client Library

onfido-python on PyPI

Version 1.3.1

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

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 base_url parameter.

The library will use the default base URL (api.onfido.com) for the EU region, if no region is specified.

To specify the US region do:

from onfido.regions import Region

api = onfido.Api("<YOUR_API_TOKEN>", base_url=Region.US)

To specify the CA region do:

from onfido.regions import Region

api = onfido.Api("<YOUR_API_TOKEN>", base_url=Region.CA)

See https://documentation.onfido.com/#regions for supported regions.

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"
  }
}

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

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

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

Uploaded Source

Built Distribution

onfido_python-1.3.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file onfido-python-1.3.1.tar.gz.

File metadata

  • Download URL: onfido-python-1.3.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.6 Darwin/20.3.0

File hashes

Hashes for onfido-python-1.3.1.tar.gz
Algorithm Hash digest
SHA256 a32c9f61fbd20a29c84a6e9a2fee4078124436571e25d1c1d6705e6a0ace0a60
MD5 871cd425fc3f150e5349c5298b1b2b89
BLAKE2b-256 ab650c488f86aa920f8af4a91df422e261b9f40ea5c9ae6a45e44de15f29f56f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: onfido_python-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.6 Darwin/20.3.0

File hashes

Hashes for onfido_python-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e74913921df158380c10bfde639fe65730ecb0a463379235082be4871b6ed5
MD5 2a0e3d4b4f034d2cb63da8f4fdd308f8
BLAKE2b-256 912c25607b01093ae4ec572cff2a76c4d4747f6f1fc4745fe9b36dc85e3534f0

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