Skip to main content

Incognia API Python Client

Project description

Incognia API Python Client 🐍

Python 3.8+ test workflow

Installation

You can install the IncogniaAPI using the following command:

pip install incognia-python

Usage

Configuration

Before calling the API methods, you need to create an instance of the IncogniaAPI class.

from incognia.api import IncogniaAPI

# to use the US region
api = IncogniaAPI('client-id', 'client-secret', 'us')

# to use the BR region
api = IncogniaAPI('client-id', 'client-secret', 'br')

Incognia API

The implementation is based on the Incognia API Reference.

Authentication

Authentication is done transparently, so you don't need to worry about it.

Registering New Signup

This method registers a new signup for the given installation and a structured address, an address line or coordinates, returning a dict, containing the risk assessment and supporting evidence:

from incognia.api import IncogniaAPI
from incognia.models import StructuredAddress, Coordinates

api = IncogniaAPI('client-id', 'client-secret')  # us region is selected by default.

# with structured address, a dict:
structured_address: StructuredAddress = {
    'locale': 'en-US',
    'country_name': 'United States of America',
    'country_code': 'US',
    'state': 'NY',
    'city': 'New York City',
    'borough': 'Manhattan',
    'neighborhood': 'Midtown',
    'street': 'W 34th St.',
    'number': '20',
    'complements': 'Floor 2',
    'postal_code': '10001'
}
assessment: dict = api.register_new_signup('installation-id', structured_address=structured_address)

# with address line:
address_line: str = '350 Fifth Avenue, Manhattan, New York 10118'
assessment: dict = api.register_new_signup('installation-id', address_line=address_line)

# with coordinates, a dict:
coordinates: Coordinates = {
    'lat': 40.74836007062138,
    'lng': -73.98509720487937
}
assessment: dict = api.register_new_signup('installation-id', address_coordinates=coordinates)

Getting a Signup

This method allows you to query the latest assessment for a given signup event, returning a dict, containing the risk assessment and supporting evidence:

from incognia.api import IncogniaAPI

api = IncogniaAPI('client-id', 'client-secret')

assessment: dict = api.get_signup_assessment('signup-id')

Registering Feedback

This method registers a feedback event for the given identifiers (optional arguments) related to a signup, login or payment.

import datetime as dt
from incognia.api import IncogniaAPI
from incognia.feedback_events import FeedbackEvents  # feedbacks are strings.

api = IncogniaAPI('client-id', 'client-secret')  # us region is selected by default.

api.register_feedback(FeedbackEvents.SIGNUP_ACCEPTED, dt.datetime.now(),
                      installation_id='installation-id',
                      account_id='account-id',
                      signup_id='signup-id')

Registering Payment

This method registers a new payment for the given installation and account, returning a dict, containing the risk assessment and supporting evidence.

from typing import List
from incognia.api import IncogniaAPI
from incognia.models import TransactionAddress, PaymentValue, PaymentMethod

api = IncogniaAPI('client-id', 'client-secret')

addresses: List[TransactionAddress] = [
    {
        'type': 'shipping',
        'structured_address': {
            'locale': 'pt-BR',
            'country_name': 'Brasil',
            'country_code': 'BR',
            'state': 'SP',
            'city': 'São Paulo',
            'borough': '',
            'neighborhood': 'Bela Vista',
            'street': 'Av. Paulista',
            'number': '1578',
            'complements': 'Andar 2',
            'postal_code': '01310-200'
        },
        'address_coordinates': {
            'lat': -23.561414,
            'lng': -46.6558819
        }
    }
]

payment_value: PaymentValue = {
    'amount': 5.0,
    'currency': 'BRL'
}

payment_methods: List[PaymentMethod] = [
    {
        'type': 'credit_card',
        'credit_card_info': {
            'bin': '123456',
            'last_four_digits': '1234',
            'expiry_year': '2027',
            'expiry_month': '10'
        }
    },
    {
        'type': 'debit_card',
        'debit_card_info': {
            'bin': '123456',
            'last_four_digits': '1234',
            'expiry_year': '2027',
            'expiry_month': '10'
        }
    }
]

assessment: dict = api.register_payment('installation-id',
                                        'account-id',
                                        'external-id',
                                        addresses=addresses,
                                        payment_value=payment_value,
                                        payment_methods=payment_methods)

Registering Login

This method registers a new login for the given installation and account, returning a dict, containing the risk assessment and supporting evidence.

from incognia.api import IncogniaAPI

api = IncogniaAPI('client-id', 'client-secret')

assessment: dict = api.register_login('installation-id', 'account-id', 'external-id')

Evidences

Every assessment response includes supporting evidence in a dict. You can find all available evidences here.

Error Handling

Every method call can throw IncogniaHTTPError and IncogniaError.

IncogniaHTTPError is thrown when the API returned an unexpected http status code.

IncogniaError represents unknown errors, like required parameters none or empty.

How to Contribute

If you have found a bug or if you have a feature request, please report them at this repository issues section.

What is Incognia?

Incognia is a location identity platform for mobile apps that enables:

  • Real-time address verification for onboarding
  • Frictionless authentication
  • Real-time transaction verification

Create a Free Incognia Account

  1. Go to Incognia and click on "Sign Up For Free"
  2. Create an Account
  3. You're ready to integrate Incognia SDK and use Incognia APIs

License

License: MIT

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

incognia-python-1.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

incognia_python-1.0.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file incognia-python-1.0.0.tar.gz.

File metadata

  • Download URL: incognia-python-1.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for incognia-python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bb951c94e426519487cc281bc830b34a97603dce9b9a3b9f04a2463591fa7520
MD5 a78e611d3e17da68a06106b3b8a62e65
BLAKE2b-256 4105ee13b252115b0ac973b13ad0bd1b9a7a9bbb248df51027aa28028784e20f

See more details on using hashes here.

File details

Details for the file incognia_python-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: incognia_python-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for incognia_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03f65d8ca043889123245f5111bea9642cf83d4a4c048ce288ba12b7d6a63f55
MD5 c43c2a4b989fe94c75cd844068b8f030
BLAKE2b-256 e1214324dc1359931073bdcbc898a511f611060a612b968b3ac9e0fe0e46bfa7

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