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:

  1. Use the /api/ledger/<ledger>/transactions endpoint.

  2. Include a JSON filter in the request body.

  3. Use the timestamp field 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:

  • $and combines multiple conditions.

  • $match specifies the account (replace "account_id" with your actual account identifier).

  • $gte sets the start date (greater than or equal to).

  • $lte sets 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.