Metadata-Version: 2.4
Name: complycube
Version: 1.1.9
Summary: Official Python client for the ComplyCube API
Author: Complycube
Author-email: tech@complycube.com
Keywords: complycube,aml,kyc,client,api,wrapper,PEP,identity verification,identity checks,document verification
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Telecommunications Industry
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Legal Industry
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.20.0
Requires-Dist: pyhumps>=1.2.0
Requires-Dist: urllib3>=1.26
Dynamic: license-file

# ComplyCube Python Library

The official python library for integrating with the ComplyCube API.

Check out the [API integration docs](https://docs.complycube.com/api-reference/integration).

Check out the [API reference](https://docs.complycube.com/api-reference/).


## Installation

```sh
pip install complycube
```

### Requirements

-   Python 3.6+

## Getting Started

import the client

```python
from complycube import ComplyCubeClient
```

Initialise the ComplyCubeClient with the api key from your [developer dashboard.](https://portal.complycube.com/developers/key)

```python
cc_api = ComplyCubeClient(api_key='test_....')
```
Create a new client and complete a standard check

```python
input_client_dict = {
    'type':'person',
    'email':'a@b.com',
    'personDetails': {
        'firstName':'John',
        'lastName':'Smith'
    }
}
cc_client = cc_api.clients.create(**input_client_dict)
check = cc_api.checks.create(cc_client.id,'standard_screening_check')
print(check)
```

Search for clients with the first name "John"
```python
for client in cc_api.clients.list(personDetails={'firstName': 'John'}):
    print(client.email)
```

The auto_list function will handle api paging automatically via a generator and return a native object.
```python
for client in cc_api.clients.auto_list(personDetails={'firstName': 'John'}):
    print(client.email)
```

### Available resources

| Property | Operations |
| --- | --- |
| `clients` | `create`, `get`, `update`, `delete`, `list`, `auto_list` |
| `addresses` | `create`, `get`, `update`, `delete`, `list` |
| `documents` | `create`, `get`, `update`, `delete`, `list`, `auto_list`, `upload`, `download`, `deleteImage`, `redact` |
| `livephotos` | `upload`, `get`, `list`, `download`, `deleteImage`, `redact` |
| `livevideos` | `get`, `list`, `delete`, `redact` |
| `checks` | `create`, `get`, `update`, `list`, `validate`, `redact` |
| `notes` | `create`, `get`, `update`, `delete`, `list`, `auto_list` |
| `riskprofiles` | `get` |
| `workflow_sessions` | `get`, `list`, `complete`, `cancel` |
| `flow` | `create` |
| `tokens` | `create` |
| `reports` | `generate_client_report`, `generate_check_report`, `generate_workflow_session_report` |
| `webhooks` | `create`, `get`, `update`, `delete`, `list` |
| `teammembers` | `get`, `list` |
| `auditlogs` | `get`, `list` |
| `custom_lists` | `get`, `list`, `add_entity` |
| `lookup` | `search_companies`, `get_company`, `search_addresses` |
| `autofill` | `perform` |
| `static` | `screening_lists`, `supported_documents` |
| `account_info` | `get` |

Add a note to a client

```python
note = cc_api.notes.create(cc_client.id, 'internal', 'Reviewed by compliance')
```

Search a company registry and fetch the full company record

```python
companies = cc_api.lookup.search_companies('Stripe Payments Europe Limited', 'IE')
for company in companies:
    details = cc_api.lookup.get_company(company.id)
    print(details.name, details.registration_number)
```

Redact a document check outcome

```python
cc_api.checks.redact(check.id, attributes=['documentNumber'], images=['face'])
```

### Handling errors

All API errors raise `ComplyCubeAPIError`, which exposes the HTTP status code, the ComplyCube error `type` and, for validation errors, the offending `param`.

```python
from complycube import ComplyCubeAPIError

try:
    cc_api.clients.create(type='person', email='invalid')
except ComplyCubeAPIError as e:
    print(e.code, e.type, e.param, e.message)
```

### Verifying webhooks

ComplyCube signs each webhook with HMAC-SHA256 in the `ComplyCube-Signature` header. Pass the raw request body, exactly as received, to the verifier.

```python
from complycube.eventverifier import EventVerifier, VerificationError

verifier = EventVerifier('<WEBHOOK_SECRET>')
try:
    event = verifier.construct_event(request.body, request.headers['ComplyCube-Signature'])
except VerificationError:
    ...  # reject the request
```

### Client Configuration

```python
cc_api = ComplyCubeClient(api_key='test_...', timeout=30, retries=5)
```

`timeout` sets the default request timeout in seconds (60 if not set). `retries` enables retries with exponential backoff for `GET` requests that fail with `429` or `5xx` responses.

### Per-request Configuration

You can set the following per-request options on any call: `timeout`, `verify`, `proxies`, `cert`, `headers` and `api_key`. They configure the HTTP request and are never sent to the API.

Setting the timeout for client creation to 5 seconds

```python
cc_api.clients.create(**input_client_dict, timeout=5)
```

Avoiding certification verification

```python
cc_api.clients.create(**input_client_dict, verify=False)
```

Passing a specific api key for a single request

```python
cc_api.clients.create(**input_client_dict, api_key='test_...')
```

### Configuring a Proxy

A proxy can be configured for all requests when creating the client:

```python
proxies = {
  'https': 'http://10.10.1.10:1080',
}
cc_api = ComplyCubeClient(api_key='test_...', proxy=proxies)
```

or for a single request:

```python
cc_api.clients.create(**input_client_dict, proxies=proxies)
```

For additional information, news and our latest blogs visit us at https://www.complycube.com/
