Coder Social home page Coder Social logo

ntropy-sdk's Introduction

Ntropy SDK

This repository hosts the SDK for the Ntropy API. To use the Ntropy API you require an API key which can be requested at ntropy.com.

The Ntropy API provides transaction enrichment and categorization, account ledger, metrics and custom model training. The full documentation is available at the developer portal.

Installation

$ python3 -m pip install --upgrade 'ntropy-sdk'

Quick Start

Enriching your first transaction requires an SDK object and an input Transaction object. The API key can be set in the environment variable NTROPY_API_KEY or in the SDK constructor:

from ntropy_sdk import SDK, Transaction

sdk = SDK("YOUR-API-KEY")
tx = Transaction(
    description = "AMAZON WEB SERVICES",
    entry_type = "outgoing",
    amount = 12042.37,
    iso_currency_code = "USD",
    date = "2021-11-01",
    transaction_id = "4yp49x3tbj9mD8DB4fM8DDY6Yxbx8YP14g565Xketw3tFmn",
    country = "US",
    account_holder_id = "id-1",
    account_holder_type = "business"
)

enriched_tx = sdk.add_transactions([tx])[0]
print(enriched_tx.merchant)

The returned EnrichedTransaction contains the added information by Ntropy API. You can consult the Enrichment section of the documentation for more information on the parameters for both Transaction and EnrichedTransaction.

Documentation

You can consult in-depth documentation and examples at the developer portal and at the SDK reference.

License:

Free software: MIT license

ntropy-sdk's People

Contributors

0e4ef622 avatar adgsantos avatar arsenyinfo avatar bagrat avatar iliazintchenko avatar jmkernes avatar jordisoler avatar jorge-pessoa avatar kevinl10 avatar levon-d avatar louisoutin avatar naanselmo avatar naorpeled avatar pauloromeira avatar robinka avatar thymo avatar wuurrd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ntropy-sdk's Issues

Invalid Syntax When Update to 4.10.1

  • Ntropy SDK version: 4.10.1
  • Python version: 3.7.1
  • Operating System: Ubuntu 18.04

Description

I update ntropy sdk version 4.8.3 to 4.10.1 then got it this error when try to run backend. error points to ntropy side. If there anyone who know this problem ?

What I Did

Upgrade sdk version from 4.8.3 to 4.10.1

image

Incompatability with Pydantic 2.0

  • Ntropy SDK version: 4.16.0
  • Python version: 3.8.12
  • Operating System: MacOS

Description

When attempting to start our Django application during CI/CD, we got the following error:

  File "/usr/local/lib/python3.8/site-packages/ntropy_sdk/ntropy_sdk.py", line 83, in <module>
    class Transaction(BaseModel):
  File "/usr/local/lib/python3.8/site-packages/ntropy_sdk/ntropy_sdk.py", line 127, in Transaction
    country: Optional[str] = Field(
  File "/usr/local/lib/python3.8/site-packages/pydantic/fields.py", line 707, in Field
    raise PydanticUserError('`regex` is removed. use `pattern` instead', code='removed-kwargs')
pydantic.errors.PydanticUserError: `regex` is removed. use `pattern` instead

For further information visit https://errors.pydantic.dev/2.0/u/removed-kwargs

It looks like it's the regex parameter to Field on line 128 of ntropy_sdk/ntropy_sdk.py. We don't need to use Pydantic 2.0 at the moment, so we'll be moving back to 1.10, but thought I'd put this here just in case y'all hadn't seen it come up yet.

When I checked the diff between 4.16 and 4.19.0rc5 I didn't see this fixed, but please of course close this issue if y'all have already handled it.

What I Did

N/A

Doesn't work with `pydantic` v2

  • Ntropy SDK version: 4.23.1
  • Python version: 3.11.6
  • Operating System: Ubuntu

Description

Although recent releases have attempted to add support for pydantic v2, it doesn't seem to work. ๐Ÿคท

What I Did

from ntropy_sdk import AccountHolder
from ntropy_sdk.utils import AccountHolderType

AccountHolder(id="boom", type=AccountHolderType.business)

And it raises the following:

Traceback (most recent call last):
  File "/workspaces/wayflyer/scratch/boom2.py", line 4, in <module>
    AccountHolder(id="boom", type=AccountHolderType.business)
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/main.py", line 176, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_mock_val_ser.py", line 41, in __getattr__
    val_ser = self._attempt_rebuild()
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_mock_val_ser.py", line 73, in attempt_rebuild_validator
    if cls.model_rebuild(raise_errors=False, _parent_namespace_depth=5) is not False:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/main.py", line 518, in model_rebuild
    return _model_construction.complete_model_class(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 539, in complete_model_class
    schema = cls.__get_pydantic_core_schema__(cls, handler)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/main.py", line 626, in __get_pydantic_core_schema__
    return handler(source)
           ^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_schema_generation_shared.py", line 82, in __call__
    schema = self._handler(source_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 502, in generate_schema
    schema = self._generate_schema_inner(obj)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 753, in _generate_schema_inner
    return self._model_schema(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 580, in _model_schema
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 580, in <dictcomp>
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 916, in _generate_md_field_schema
    common_field = self._common_field_schema(name, field_info, decorators)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 1081, in _common_field_schema
    schema = self._apply_annotations(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 1825, in _apply_annotations
    schema = get_inner_schema(source_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_schema_generation_shared.py", line 82, in __call__
    schema = self._handler(source_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 1806, in inner_handler
    schema = self._generate_schema_inner(obj)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 758, in _generate_schema_inner
    return self.match_type(obj)
           ^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 840, in match_type
    return self._match_generic_type(obj, origin)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 864, in _match_generic_type
    return self._union_schema(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 1152, in _union_schema
    choices.append(self.generate_schema(arg))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 502, in generate_schema
    schema = self._generate_schema_inner(obj)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 758, in _generate_schema_inner
    return self.match_type(obj)
           ^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 844, in match_type
    return self._unknown_type_schema(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/wayflyer/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 405, in _unknown_type_schema
    raise PydanticSchemaGenerationError(
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'ntropy_sdk.ntropy_sdk.SDK'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.

For further information visit https://errors.pydantic.dev/2.7/u/schema-for-unknown-type

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.