Skip to main content

SDK for the Ntropy API

Project description

Ntropy SDK

SDK for the Ntropy API

Installation:

$ pip install --upgrade 'ntropy-sdk[benchmark]'

Usage:

import os
import uuid
from datetime import datetime
from ntropy_sdk import SDK, Transaction, AccountHolder

sdk = SDK(os.getenv("NTROPY_API_KEY"))

for account_holder_type in ['business', 'consumer', 'freelance', 'unknown']:
  print("ACCOUNT HOLDER TYPE:", account_holder_type)
  print(sdk.get_labels(account_holder_type))

print("CHART of ACCOUNTS:", sdk.get_chart_of_accounts())

account_holder = AccountHolder(
    id=str(uuid.uuid4()),
    type="business",
    name="Ntropy Network Inc.",
    industry="fintech",
    website="ntropy.com"
)
sdk.create_account_holder(account_holder)

transaction = Transaction(
    amount=12046.15,
    date="2021-12-13",
    description="AMAZON WEB SERVICES AWS.AMAZON.CO WA Ref5543286P25S: Crd15",
    entry_type="outgoing",
    iso_currency_code="USD",
    account_holder_id=account_holder.id,
    country="US",
)

transaction_list = [transaction]

enriched_transactions = sdk.add_transactions(transaction_list)
print("ENRICHED:", enriched_transactions)

query = account_holder.get_metrics(['amount'], start=datetime.strptime("2021-12-01", "%Y-%m-%d"), end=datetime.strptime("2022-01-01", "%Y-%m-%d"))
print("QUERY:", query['amount'])

import pandas as pd

df = pd.DataFrame(data = [[12046.15, '2021-12-13', "AMAZON WEB SERVICES AWS.AMAZON.CO WA Ref5543286P25S: Crd15", 'outgoing', 'USD', 'US', str(uuid.uuid4()), 'business', "Ntropy Network Inc.", "fintech", "ntropy.com"]], columns = ["amount", "date", "description", "entry_type", "iso_currency_code", "country", "account_holder_id", "account_holder_type", "account_holder_name", "account_holder_industry", "account_holder_website"])

def create_account_holder(row):
    sdk.create_account_holder(
        AccountHolder(
            id=row["account_holder_id"],
            type=row["account_holder_type"],
            name=row.get("account_holder_name"),
            industry=row.get("account_holder_industry"),
            website=row.get("account_holder_website"),
        )
    )

df.groupby("account_holder_id", as_index=False).first().apply(create_account_holder, axis=1)

enriched_df = sdk.add_transactions(df)
print("ENRICHED:", enriched_df)

Programmatic usage for benchmarking:

Assuming you have a CSV file called testset.csv with the following fields set:

  • iso_currency_code: The currency of the transaction
  • amount: The amount (a positive number)
  • entry_type: incoming for money coming into the account, outgoing for money going out of the account
  • description: The transaction description string
  • account_holder_id: A unique identifier for the account holder
  • account_holder_type: A string indicating the type of the account of the transaction (business or consumer)
  • (optional) correct_merchant: A string that should match the merchant output of the API. If you combine this with --ground-truth-merchant-field=correct_merchant you will be given an accuracy % for the API.
  • (optional) correct_labels: The label that the transaction should be marked as. If you combine this with --ground-truth-label-field=correct_labels you will be given an F1 score for the API.
$ ntropy-benchmark --api-key=$NTROPY_API_KEY --in-csv-file=testset.csv --out-csv-file=enriched.csv --ground-truth-label-field=correct_labels

License:

Free software: MIT license

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ntropy_sdk-4.2.3rc5.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

ntropy_sdk-4.2.3rc5-py2.py3-none-any.whl (11.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ntropy_sdk-4.2.3rc5.tar.gz.

File metadata

  • Download URL: ntropy_sdk-4.2.3rc5.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for ntropy_sdk-4.2.3rc5.tar.gz
Algorithm Hash digest
SHA256 dcdd042d42908934720176ef408dd117c29136bdf0c9a3701d79fcdfc82d13f9
MD5 433430837fa5f62c76dc1a077d626326
BLAKE2b-256 f2eb5e1fd398b49f9740b2515fee7f767812a9fac4b6d10feed94ed79da96b35

See more details on using hashes here.

File details

Details for the file ntropy_sdk-4.2.3rc5-py2.py3-none-any.whl.

File metadata

  • Download URL: ntropy_sdk-4.2.3rc5-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for ntropy_sdk-4.2.3rc5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c79008fa73990311e1106b12b81b8aa19933f8e43c5467c6026753f623f47142
MD5 62ce4b42c3248e3cd75261d5e262aff6
BLAKE2b-256 f81838e4090df7da1c863fb701f0e29067f81afa04eafc0db82b17ad198721c5

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