Skip to main content
POST
/
{collection}
/
filter
Search via DB
curl --request POST \
  --url http://localhost:5001/{collection}/filter \
  --header 'X-blnk-key: <api-key>'
import requests

url = "http://localhost:5001/{collection}/filter"

headers = {"X-blnk-key": "<api-key>"}

response = requests.post(url, headers=headers)

print(response.text)
const options = {method: 'POST', headers: {'X-blnk-key': '<api-key>'}};

fetch('http://localhost:5001/{collection}/filter', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_PORT => "5001",
CURLOPT_URL => "http://localhost:5001/{collection}/filter",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-blnk-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "http://localhost:5001/{collection}/filter"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("X-blnk-key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("http://localhost:5001/{collection}/filter")
.header("X-blnk-key", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("http://localhost:5001/{collection}/filter")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["X-blnk-key"] = '<api-key>'

response = http.request(request)
puts response.read_body
Use blnk.search.filter to filter records in a collection.
1

Call the method

blnk.search.filter
response = blnk.search.filter(
  {
    "filters": [
      {
        "field": "status",
        "operator": "eq",
        "value": "APPLIED",
      },
    ],
    "logical_operator": "and",
    "sort_by": "created_at",
    "sort_order": "desc",
    "include_count": True,
    "limit": 20,
    "offset": 0,
  },
  "transactions",
)
FieldTypeDescription
filterslist[dict]Array of filter conditions, each with a field, operator, and a value or values.
logical_operatorstrCombine filters with and or or. Defaults to and.
sort_bystrField to sort by. Defaults to created_at.
sort_orderstrSort direction, asc or desc. Defaults to desc.
include_countboolReturn total_count in the response. Defaults to False.
limitnumberMaximum records to return. Defaults to 20, max 100.
offsetnumberRecords to skip for pagination. Defaults to 0.
collectionstrCollection to filter: ledgers, transactions, balances, or identities.
2

Use the filtered results

Read response.data["data"] for matching records. Use total_count with limit and offset to paginate when include_count is True.
3

Response

200 OK
{
  "data": [
    {
      "transaction_id": "txn_abc123",
      "amount": 15000,
      "currency": "USD",
      "status": "APPLIED",
      "source": "bln_source123",
      "destination": "bln_dest456",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "total_count": 150
}
FieldTypeDescription
datalist[dict]Array of matching records. Shape varies by collection.
total_countnumberTotal matching records. Only present when include_count is True.

How DB filtering works

Supported operators and field reference.

Search via DB

HTTP request and response schema.

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.