Label hierarchies
The labels returned by the API are different depending on the account_holder_type
of the transaction. You can find the listing containing all the labels for each account_holder_type
below:
Custom Hierarchies​
In addition to the default label hierarchies, Ntropy allows you to define and use custom hierarchies for your specific needs. This feature enables you to tailor the labels system to your unique use case.
Defining a Custom Hierarchy​
To define a custom hierarchy, you need to create a JSON structure that represents your desired label organization. The structure should contain two main categories: "incoming" and "outgoing", each containing an array of labels.
Here's an example of how to define a custom hierarchy:
{
"incoming": [
"salary",
"investment income",
"other income"
],
"outgoing": [
"rent",
"utilities",
"groceries",
"entertainment"
]
}
Uploading a Custom Hierarchy​
To upload a custom hierarchy, you can use either the Ntropy SDK or cURL. Choose the method that best fits your workflow.
- cURL
- Python SDK
curl -H "X-API-KEY: your_api_key_here" \
-H "Content-Type: application/json" \
-X POST \
--data '{
"incoming": ["salary", "investment income", "other income"],
"outgoing": ["rent", "utilities", "groceries", "entertainment"]
}' \
https://api.ntropy.com/v2/labels/hierarchy/custom/consumer
from ntropy_sdk import NtropySDK
sdk = NtropySDK(api_key="your_api_key_here")
custom_hierarchy = {
"incoming": ["salary", "investment income", "other income"],
"outgoing": ["rent", "utilities", "groceries", "entertainment"]
}
sdk.create_custom_hierarchy(account_holder_type="consumer", custom_hierarchy=custom_hierarchy)
Using a Custom Hierarchy​
After uploading your custom hierarchy, Ntropy will automatically use it for labeling transactions associated with your API key. The custom labels will replace the default labels in the enrichment results.
Retrieving a Custom Hierarchy​
You can retrieve your current custom hierarchy using either the Ntropy SDK or cURL.
- cURL
- Python SDK
curl -H "X-API-KEY: your_api_key_here" \
https://api.ntropy.com/v2/labels/hierarchy/custom/consumer
from ntropy_sdk import NtropySDK
sdk = NtropySDK(api_key="your_api_key_here")
custom_hierarchy = sdk.get_custom_hierarchy(account_holder_type="consumer")
print(custom_hierarchy)
Deleting a Custom Hierarchy​
To remove a custom hierarchy and revert to the default labels, you can use either the Ntropy SDK or cURL.
- cURL
- Python SDK
curl -H "X-API-KEY: your_api_key_here" \
-X DELETE \
https://api.ntropy.com/v2/labels/hierarchy/custom/consumer
from ntropy_sdk import NtropySDK
sdk = NtropySDK(api_key="your_api_key_here")
sdk.delete_custom_hierarchy(account_holder_type="consumer")
Special Labels​
In cases where there is not enough information to accurately classify a transaction, the API will return a special label:
- "not enough information": This label is used when the available transaction data is insufficient to determine a specific category.
This ensures that transactions are not incorrectly labeled when the data is ambiguous or incomplete.
By using custom hierarchies, you can ensure that the transaction labels align perfectly with your specific requirements while still leveraging Ntropy's powerful labeling capabilities.