# Get Transactions
source: https://developer.mastercard.com/open-finance-europe/documentation/unlicensed/aiia-data/transactions/index.md

## Get Transactions {#get-transactions}

The Get Transactions endpoint enables you to access financial transactions from different accounts within a chosen period of time.

An example of how receive transactions from a specific account is shown below:

API Reference: `GET /v1/accounts/{accountId}/transactions`

```shell
curl -X GET
  https://api-sandbox.aiia.eu/v1/accounts/{accountId}/transactions \
  -H 'Authorization: Bearer ACCESS_TOKEN'
```

#### Parameters {#parameters}

|         **Name**          | **Required** | **Type**  |                                             **Description**                                              |
|---------------------------|--------------|-----------|----------------------------------------------------------------------------------------------------------|
| `accountId`               | Yes          | `string`  | Account id received from `/v1/accounts`                                                                  |
| `pagingToken`             | No           | `string`  | A paging token received from a previous request for transactions                                         |
| `pageSize`                | No           | `number`  | How many transactions you want returned per request                                                      |
| `showNagMigrationDetails` | No           | `boolean` | Indicates if you want to use the `nagApiAccountId` to aid in migration from Aiia Enterprise to Aiia Data |
| `includeDeleted`          | No           | `boolean` | Indicates if you want to receive transactions that have been soft-deleted                                |

**Are you having trouble?**

Ensure you have a valid access token after completing the Connect Flow described in the [Quick Sstart Guide](https://developer.mastercard.com/open-finance-europe/documentation/unlicensed/aiia-data/quickstart/index.md).

**Saving transactions**   
If you are saving transactions on your side, you should always delete transactions that are older than two years. Do not just mark them as deleted. In order to be compliant with PSD2, transactions that are more than two years old are deleted.

#### Result {#result}

The call returns the following JSON object:

```json
{
    "pagingToken": "...", 
    "transactions": [
        {
            "accountId": "ZmExODkyNzEtZjk2NS00ZjVjLTk5Z6782tZTQ1YjczYmMyODM5fFRlc3REYXRhQmFuazF8bkx5dXRxZlYwdnkwaElSSW9wNnRDakVHenllUFMyem43UVl2LUpWT3YwUS4w",
            "amount": -291.0,
            "balance": {
                "currency": "DKK",
                "value": -3954.0
            },
            "estimatedBalance": {
                "currency": "DKK",
                "value": -3954.0
            },
            "creationDate": "0001-01-01T00:00:00",
            "currency": "DKK",  
            "date": "2019-09-02",
            "detail": {...}, // You need to contact sales to get this info, otherwise it is just null
            "id": "8f6b6b78-6e97-73ba-a6de-4a732fcff09bd",
            "nagApiTransactionId": null,
            "originalText": "DSB Kastrup AUT    23228",
            "state": "Booked",
            "text": "DSB Kastrup AUT",
            "transactionAmount": {
                "currency": "DKK",
                "value": -291.0
            },
            "type": "Card"
        },
        ...,
    ]
}
```

The transaction object contains a lot of information, including:

* The date of the transaction
* A description
* The amount of the transaction and the current state

Note: The data in the sandbox is not guaranteed to be persistent over time as we delete data from time to time.

|       **Name**        |  **Type**  |                                                                                                               **Description**                                                                                                                |
|-----------------------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `accountId`           | `string`   | ID of the account that the transaction was retrieved from                                                                                                                                                                                    |
| `amount`              | `string`   | The transacted amount in a specific currency                                                                                                                                                                                                 |
| `balance`             | `object`   | The account balance after the transaction, along with the ISO 4217 currency code ([website](https://www.currency-iso.org/en/home/tables/table-a1.html))                                                                                      |
| `creationDate`        | `datetime` | Creation date and time, if available. Often more meaningful to the user than the booked date                                                                                                                                                 |
| `currency`            | `string`   | The ISO 4217 currency code of the transaction([website](https://www.currency-iso.org/en/home/tables/table-a1.html))                                                                                                                          |
| `date`                | `datetime` | The booked date of the transaction                                                                                                                                                                                                           |
| `details`             | `object`   | Additional transaction details, including the transaction source, destination, execution date, etc.                                                                                                                                          |
| `id`                  | `string`   | This identifier is unique within a single account                                                                                                                                                                                            |
| `nagApiTransactionId` | `string`   | Transaction ID from Aiia Enterprise which is useful for migrations.                                                                                                                                                                          |
| `originalText`        | `string`   | The transaction text from the provider                                                                                                                                                                                                       |
| `state`               | `string`   | Current transaction state which can have one of the following values: `Booked`, `Reserved`, `Scheduled`. Note that when a transaction changes state, it will most likely get a new `id`                                                      |
| `text`                | `string`   | A user-friendly version of the 'OriginalText'. May be identical to 'OriginalText' if no cleanup could be done                                                                                                                                |
| `transactionAmount`   | `object`   | The amount of transacted currency, along with the ISO 4217 currency code ([website](https://www.currency-iso.org/en/home/tables/table-a1.html)). Debits are represented in negative numbers and deposits are represented in positive numbers |
| `type`                | `string`   | Transaction type from the provider which can have one of the following values: `Unknown`,`InternalCounterEntry`, `Card`, `PeerToPeer`, `DirectDebit`, `BankTransfer`, `CashWithdrawal`                                                       |
| `pagingToken`         | `string`   | If the account has more transactions than possible to fetch with a single request, you can fetch more transactions by providing this token in a new request                                                                                  |

#### Transaction details {#transaction-details}

If the transaction details feature is enabled, each transaction `details` property will be populated with the information available from the provider. If the transaction details feature has not been been enabled, the `details` property will be `null`. Note that we only fetch details from accounts which support unattended log in, and we only fetch details from the day that the user connects the account to our service.  
Available details vary from bank to bank and integration to integration (PSD2 vs. PSD2 compliant fallback/reversed) and some banks do not yet offer any transaction details at all. For now we will be unable to provide you with information and support to which banks provide which details in which quality.
Note: Transaction details are updated only once in a 24-hour period compared to other data which is updated every 6 hours.

```json
...
   "detail": { // You need to contact sales to get this info, otherwise it is just null
      "currencyConversion": null,
      "destination": {
          "account": null,
          "address": null,
          "merchantCategoryCode": null,
          "merchantCategoryName": null,
          "name": "DSB Kastrup AUT    23228"
      },
      "executionDate": null,
      "identifiers": {
          "creditorReference": null,
          "document": null,
          "endToEndId": null,
          "reference": "0130Y9C6LY212",
          "sequenceNumber": null,
          "terminal": null
      },
      "message": null,
      "reward": null,
      "source": {
          "account": {
              "bban": null,
              "bbanParsed": null,
              "bbanType": null,
              "card": {
                  "cardHolder": "Henrik Madsen",
                  "expireMonth": null,
                  "expireYear": null,
                  "maskedPan": "0524 XXXX XXXX 3413"
              },
              "iban": null
          },
          "address": null,
          "merchantCategoryCode": null,
          "merchantCategoryName": null,
          "name": null
      },
      "valueDate": null
  },
...
```

## Query Transactions {#query-transactions}

The Query Transaction endpoint enables better control over the type of transactions that are returned.

The endpoint expects a body containing the following details:

|       **Name**        |          **Type**          |                                                                          **Description**                                                                           |
|-----------------------|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `amountValueBetween`  | `FieldBetween` (see below) | Filter to filter transactions that have amount between specified boundaries                                                                                        |
| `balanceValueBetween` | `FieldBetween` (see below) | Filter to filter transactions that have account balance between specified boundaries                                                                               |
| `interval`            | `string`                   | ISO 8601 interval represented as a string                                                                                                                          |
| `pageSize`            | `number`                   | Amount of transactions to return in a single request. If one page does not cover all transactions that can be returned using this query, `pagingToken` is returned |
| `pagingToken`         | `string`                   | If `pagingToken` was received in a previous request, it can be provided here to get additional page of transactions                                                |

###### FieldBetween {#fieldbetween}

| **Name** | **Required** |     **Type**     |
|----------|--------------|------------------|
| `min`    | `number`     | Smaller boundary |
| `max`    | `number`     | Bigger boundary  |

#### Example {#example}

An examples query to find first 10 transactions with amount between 5000 and 20000 that happened between `2018-01-01` and `2020-01-01` is shown below:

API Reference: `POST /v1/accounts/{accountId}/transactions/query`

```shell
curl -X POST \
  https://api-sandbox.aiia.eu/v1/accounts/{accountId}/transactions/query \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json'  \
  -d '{
        "interval": "2018-01-01T12:00:00Z/2020-01-01T00:00:00Z",
        "pageSize": 10,
        "amountValueBetween": {
                "min": 5000,
                "max": 20000
            }
      }' 
```

##### Result {#result-1}

The call returns the following JSON object:

```json
{
    "pagingToken": "W3siY29tcG9zaXRlVG9rZW4iOnsidG9rZW4iOiIrUklEOn5zSXhEQUprVlVIeklsZ0FBQUFBQUFBPT0jUlQ6MSNUUkM6MTAjUlREOmN4dmtxRDdZR2xzQ21BRnFMV1doQk1BSSNJU1Y6MiNJRU86NjU1NTEjRlBDOkFnRUNTQUlJQUpFVzRQK2hRQU1BQlFRQTBSQ0FBd1lFQUxFK2ZBQXdCQUFSQ2dEL05RWUFBc0FBL1A4RFJRUUFrUmFBZjBnR0FCSWNBTUEvQUE9PSIsInJhbmdlIjp7Im1pbiI6IiIsIm1heCI6IkZGIn19LCJvcmRlckJ5SXRlbXMiOlt7Iml0ZW0iOjN9XSwicmlkIjoic0l4REFKa1ZVSHlzbGdBQUFBQUFBQT09Iiwic2tpcENvdW50IjowLCJmaWx0ZXIiOm51bGx9XQ",
    "transactions": [
        {
            "accountId": "NjNhZmQ1NWEtNzkyNi00YmZjLTk2MjctN2FiMTM4YjMxZjE2fFRlc3REYXRhQmFuazF8MjQ5WnByeDExYkhuR1EyV00xajhEUDRaQXB5SE1rTHUwVk15bzYyZTIyUS5hMjllNDEwZDYwMTc=",
            "amount": 15512.0,
            "balance": {
                "currency": "DKK",
                "value": 27551.95
            },
            "creationDate": "0001-01-01T00:00:00",
            "currency": "DKK",
            "date": "2018-08-01",
            "detail": null,
            "estimatedBalance": {
                "currency": "DKK",
                "value": 27551.95
            },
            "id": "dccd20b9-b4db-4e50-8300-7c544139d0da",
            "isDeleted": false,
            "nagApiTransactionId": null,
            "originalText": "SalaryNovember",
            "state": "Booked",
            "text": "Salary November",
            "transactionAmount": {
                "currency": "DKK",
                "value": 15512.0
            },
            "type": "BankTransfer",
            "categories": [
                {
                    "id": "123",
                    "names": {
                        "en": "Transfer",
                        "da": "Overførsel"
                    },
                "parentId": "12",
                "setId": "DK"
                }
            ]
        },
        ...,
    ]
}
```

You are now ready to fetch transaction data from your end-users' accounts.
Note: We do everything possible to return transactions in the same order as the bank. However, we don't expose a sorting property, so if your product needs the right order, it is up to you to make these indexes.
