Filtering responses

Use filters to reduce responses sizes and bandwidth, ensuring you get just the data you need.

Using filters in your request can significantly cut down on the response size from the server as well as ensure that you eliminate any of the data that you don't need to get the job done.

Get only certain fields

You can use the fields filter in your URL query to define which fields:

  • You want returned in your response.
    fields=field1,field2
  • You want excluded in your response.
    omit=field1,field2

📘

You can only target first-level fields, which will return any nested fields.

For example, when querying the accounts endpoint, instead of receiving the entire response from the server, you can add ?fields=id,balance to the end of your query to get just the account ID and the balance (see the Filtered tab in the code example below).

GET https://sandbox.belvo.com/api/accounts/5a772f98-befc-4217-8ae7-a087e73a7c28/

HTTP/1.1 200 OK
Content-Type: application/json
Content-Size: 341 Bytes # Unfiltered size

{
  "id":"5a772f98-befc-4217-8ae7-a087e73a7c28",
  "type":"Créditos",
  "name":"CRED PREST BANAMEX",
  "number":null,
  "category":"LN",
  "collected_at":"2019-08-13T08:00:44.251929Z",
  "bank_product_id":"18",
  "currency":"MXN",
  "balance": {
      "current": 63054.93,
      "available": 62985.22
  },
  "link":"2259b916-41ec-4dcb-9a01-7865d9c0657e",
  "internal_identification":"1"
}
GET https://sandbox.belvo.com/api/accounts/
5a772f98-befc-4217-8ae7-a087e73a7c28/?fields=id,balance # Filtered query

HTTP/1.1 200 OK
Content-Type: application/json
Content-Size: 73 Bytes # Returned filtered response

{
  "id":"5a772f98-befc-4217-8ae7-a087e73a7c28",
  "balance": {
      "current": 63054.93,
      "available": 62985.22
  }
}

Filter response data

You can use additional filters in your URL query to narrow down the responses you receive. Belvo supports the following operators for your queries:

📘

Filterable fields per endpoint

To know which fields you can filter, check out our API reference docs.

If you find that you aren't able to filter a certain field and would like to, please reach out to Belvo Support at [email protected].

OperatorUse when you wantExample
=To get results that exactly match a value.fieldA=OpenFinance
gtTo get results that are greater than a given value.fieldA__gt=5000
ltTo get results that are smaller than a given value.fieldA__lt=6000
gteTo get results that are greater than or equal to a given value.fieldA__gte=5000
lteTo get results that are smaller than or equal to a given value.fieldA__lte=6000
inTo get results for any of the listed elements. Works with strings.fieldA__in=monday,wednesday,friday
rangeTo get results that are between two values. Works with dates and numbers. Separate the two values with a comma.fieldA__range=1,5
&To combine queries.query1&query2

To use the operators, just add them to the end of the query field (remember to use double underscores, __, between the field and the operator). The example below will only return accounts where the currency is COP and the balance_available is between 3000 and 5000:

Target nested fields

You might want to target nested fields within the response. In the example below, if you wanted to target the current field, then the query path would be: account__balance__current. Please note that double underscores (__) are used to indicate that a field is nested within another field.

"accounts":{
   "link":"57f212dc-1ba4-407f-b7f0-15a5e5ff17ae",
   "category":"CHECKING_ACCOUNT",
   "type":"Cuentas de efectivo",
   "number":"002180700688677950",
   "balance":{
      "available":4523.48,
      "current":4523.48
   }
}

Examples

Below you'll see some examples of how to apply filters to your calls 🤓.

Transaction equal to a given ID

Use id={the-id-you-want}:

https://api.belvo.com/api/transactions/?id=2259b916-41ec-4dcb-9a01-7865d9c0657e

Transactions from an account with certain balance

Use account__balance__current__gt={value} . You'll need to use double underscores to get the current balance as the current field is nested with balance and account:

https://api.belvo.com/api/transactions/?account__balance__current__gt=1000

Account details for one of many account IDs

Use id__in={id1},{id2},{id3}:

https://api.belvo.com/api/accounts/?id__in=
2259b916-41ec-4dcb-9a01-7865d9c0657e,
5a772f98-befc-4217-8ae7-a087e73a7c28,
574d4a4f-1101-4bb0-bb7c-e27a440af507

Links with a certain external_id

Use external_id={id}:

https://api.belvo.com/api/links/?external_id={id}