How to filter transactions by date range in Ledger API
Last updated: September 2, 2025
When working with the Ledger API to retrieve transactions for a specific date range, it's important to use the correct filtering method. This article explains how to properly filter transactions by date in the Ledger API.
Using filters instead of query parameters
In version 2 of the Ledger API, the start_time and end_time query parameters have been deprecated. Instead, you should use the filtering functionality in the request body to specify date ranges for transactions.
How to filter transactions by date
To filter transactions by date, follow these steps:
Use the
/api/ledger/<ledger>/transactionsendpoint.Include a JSON filter in the request body.
Use the
timestampfield with appropriate operators to specify the date range.
Example filter
Here's an example of how to structure your filter to retrieve transactions for a specific account within a date range:
{
"$and": [
{
"$match": { "destination": "account_id" }
},
{
"$gte": { "timestamp": "2024-12-09T00:00:000Z" }
},
{
"$lte": { "timestamp": "2024-12-31T23:59:59Z" }
}
]
}In this example:
$andcombines multiple conditions.$matchspecifies the account (replace "account_id" with your actual account identifier).$gtesets the start date (greater than or equal to).$ltesets the end date (less than or equal to).
Available operators
You can use the following operators to filter by date:
$gt: Greater than$gte: Greater than or equal to$lt: Less than$lte: Less than or equal to
Additional resources
For more information on advanced filtering options, refer to the Formance Ledger filtering documentation.