Faceting gives you total counts for any field in your results. It helps you build filters and understand how your data is grouped. You can:
Count transactions per currency
See how many transactions are in each status
Group balances by ledger or identity
Break transactions into date or amount ranges
Quick start
Here’s a basic faceting request that shows the total counts for the status and currency fields:
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
-H "X-Blnk-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": "*",
"facet_by": "status,currency"
}'
{
"facet_counts" : [
{
"counts" : [
{
"count" : 1000 ,
"highlighted" : "APPLIED" ,
"value" : "APPLIED"
},
{
"count" : 1500 ,
"highlighted" : "INFLIGHT" ,
"value" : "INFLIGHT"
}
{
"count" : 500 ,
"highlighted" : "REJECTED" ,
"value" : "REJECTED"
}
],
"field_name" : "status" ,
"stats" : {
"total_values" : 1
}
},
{
"counts" : [
{
"count" : 876 ,
"highlighted" : "GBP" ,
"value" : "GBP"
},
{
"count" : 821 ,
"highlighted" : "EUR" ,
"value" : "EUR"
},
{
"count" : 803 ,
"highlighted" : "USD" ,
"value" : "USD"
}
],
"field_name" : "currency" ,
"stats" : {
"total_values" : 3
}
}
]
}
See all 50 lines
Field Description field_nameThe field being faceted. valueA unique value found in that field. countNumber of documents that have this value. countsThe full list of values and their counts. total_valuesHow many unique values exist for this field.
Combining faceting with filters
Faceting becomes more powerful when combined with filters. You can facet on one field while filtering on others to analyze specific subsets of your data.
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
-H "X-Blnk-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": "*",
"filter_by": "currency:=USD",
"facet_by": "status"
}'
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/balances" \
-H "X-Blnk-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": "*",
"filter_by": "identity_id:=idt_28f25ef6-2e0d-4fa6-891c-37fc409d654e",
"facet_by": "currency"
}'
The example above allows you to answer questions like:
“Of all my USD transactions, how many are in each status?”
“For this specific customer, how many balances do they have in each currency?""
You can also facet on metadata objects.
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
-H "X-Blnk-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": "*",
"facet_by": "meta_data.transaction_type,meta_data.payment_method"
}'
Always use dot notation to access nested metadata fields: meta_data.field_name
Need help?
We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool.
To ask questions or discuss issues, please contact us or join our Discord community .