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, create a JSON structure with incoming and outgoing objects that map every label to its classification criteria.
Here's an example of how to define a custom hierarchy:
{
"incoming": {
"salary": "Income paid by an employer as wages or salary.",
"investment income": "Income earned from investments.",
"other income": "Income not covered by another available label."
},
"outgoing": {
"rent": "Payment for ongoing use of a residence or property.",
"utilities": "Payment for household utility services.",
"groceries": "Purchase of food and household staples.",
"entertainment": "Payment for recreation or 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": "Income paid by an employer as wages or salary.",
"investment income": "Income earned from investments.",
"other income": "Income not covered by another available label."
},
"outgoing": {
"rent": "Payment for ongoing use of a residence or property.",
"utilities": "Payment for household utility services.",
"groceries": "Purchase of food and household staples.",
"entertainment": "Payment for recreation or entertainment."
}
}' \
https://api.ntropy.com/v2/labels/hierarchy/custom/consumer
from ntropy_sdk import SDK
sdk = SDK(api_key="your_api_key_here")
custom_hierarchy = {
"incoming": {
"salary": "Income paid by an employer as wages or salary.",
"investment income": "Income earned from investments.",
"other income": "Income not covered by another available label."
},
"outgoing": {
"rent": "Payment for ongoing use of a residence or property.",
"utilities": "Payment for household utility services.",
"groceries": "Purchase of food and household staples.",
"entertainment": "Payment for recreation or 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 SDK
sdk = SDK(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 SDK
sdk = SDK(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.