# Accounts and Transactions
source: https://developer.mastercard.com/open-finance-europe/documentation/unlicensed/aiia-data/tutorials/data-accounts-transactions-tutorial/index.md

This tutorial guides you through the process of connecting to a user's account, reading their accounts info and transactions details.

1. The first step allows you to retrieve a list of accounts for your user. You can then use an `accountId` when making subsequent calls.

2. Retrieve a specific account details.

3. Retrieve the transactions associated with a specific account.

4. Retrieve a specific transaction details.

#### Prerequisites: {#prerequisites}

* The user has gone through Connect Flow and you retrieved an `ACCESS_TOKEN`.
* This tutorial uses `curl` in order to send requests and receive responses.

### Step 1 - Accounts Retrieval {#step-1---accounts-retrieval}

Use the `accessToken` retrieved from the previous tutorial to read the user accounts.

API Reference: `GET /v1/accounts`

#### Request {#request}

* Use the `ACCESS_TOKEN` retrieved from the previous tutorial to get the user accounts.

```shell
curl -X GET https://api.aiia.eu/v1/accounts \ 
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
```

#### Response {#response}

If the request is successful, the response will look like:

```json
{
  "accounts": [
    {
        "accountProvider": {
            "id": "TestDataBank1",
            "name": "Test bank with data #1 DKK"
        },
        "available": {
            "currency": "DKK",
            "value": 6439.15
        },
        "availableBalance": null,
        "booked": {
            "currency": "DKK",
            "value": 6439.15
        },
        "bookedBalance": 6439.15,
        "currency": "DKK",
        "id": "ZmExODkyNzEtZjk2NS00ZjVjLTk5ZjktZTQ1Y682zYmMyODM5fFRlc3REYXRhQmFuazF8N2aXM5ZFIzd0gzLWhSNWJhY21nSEZCdy4x",
        "isOrphaned": false,
        "lastSynchronized": "2019-09-02T08:52:16.5816944Z",
        "nagApiAccountId": "T6t4Pk9uNDgiz7JCKcK3vis9dR3wH3-hR5bacmgHFBw.1",
        "name": "Direct Debit",
        "number": {
            "bban": "0001-245787654",
            "bbanParsed": {
                "accountNumber": "245787654",
                "bankCode": "0001"
            },
            "bbanType": "0001-245787654",
            "card": null,
            "iban": null
        },
        "owner": "Christian Thomsen",
        "syncStatus" : "Queued",
        "type": "Consumption"
    }
  ]
}
```

* Record the `id` to retrieve a specific account or to get the transactions associated with the account.

### Step 2 - Retrieve specific Account Information {#step-2---retrieve-specific-account-information}

Use the `accessToken` retrieved from the previous tutorial along with the `accountId` to read the account information.

API Reference: `GET /v1/accounts/{id}`

#### Request {#request-1}

* Use the `ACCESS_TOKEN` retrieved from the previous tutorial.

* Use the `ACCOUNT_ID` retrieved from the previous step to get a specific account details.

```shell
curl -X GET https://api.aiia.eu/v1/accounts/<ACCOUNT_ID> \ 
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
```

#### Response {#response-1}

If the request is successful, the response will look like:

```json
{
    "accountProvider": {
        "id": "TestDataBank1",
        "name": "Test bank with data #1 DKK"
    },
    "available": {
        "currency": "DKK",
        "value": 6439.15
    },
    "availableBalance": null,
    "booked": {
        "currency": "DKK",
        "value": 6439.15
    },
    "bookedBalance": 6439.15,
    "currency": "DKK",
    "id": "ZmExODkyNzEtZjk2NS00ZjVjLTk5ZjktZTQ1Y682zYmMyODM5fFRlc3REYXRhQmFuazF8N2aXM5ZFIzd0gzLWhSNWJhY21nSEZCdy4x",
    "isOrphaned": false,
    "lastSynchronized": "2019-09-02T08:52:16.5816944Z",
    "nagApiAccountId": "T6t4Pk9uNDgiz7JCKcK3vis9dR3wH3-hR5bacmgHFBw.1",
    "name": "Direct Debit",
    "number": {
        "bban": "0001-245787654",
        "bbanParsed": {
            "accountNumber": "245787654",
            "bankCode": "0001"
        },
        "bbanType": "0001-245787654",
        "card": null,
        "iban": null
    },
    "owner": "Christian Thomsen",
    "syncStatus" : "Queued",
    "type": "Consumption"
}
```

* Record the `id` to retrieve the transactions.

### Step 3 - Transactions Retrieval {#step-3---transactions-retrieval}

Use the `accessToken` retrieved from the previous tutorial along with the `accountId` to get the account transactions.

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

#### Request {#request-2}

* Use the `ACCESS_TOKEN` retrieved from the previous tutorial.

* Use the `ACCOUNT_ID` retrieved from the previous step to get the account transactions.

```shell
curl -X GET https://api.aiia.eu/v1/accounts/<ACCOUNT_ID>/transactions \ 
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
```

#### Response {#response-2}

If the request is successful, the response will look like:

```json
{
  "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",
      "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"
    }
  ],
  "pagingToken": "iQEAAAVDaXBoZXJ0ZXh0ADkBAAAA0euJxDW5HdQl0U3_TZ3Knem0MWDjn0B9jEiMxgMsPIzaWW2tv86fzieeZqB0Tdr76MurtldQhKCs86WUklZhboxqrZ3RFPrKv9t6hg3uKfae9w8bO7Y32LmJhPUTFpaMqhmZZvCbO"
}
```

* Record the `id` to retrieve a specific transaction details.

### Step 4 - Retrieve specific Transaction Details {#step-4---retrieve-specific-transaction-details}

Use the `accessToken` retrieved from the previous tutorial along with the `accountId` and `transactionId` to get a specific transaction details.

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

#### Request {#request-3}

* Use the `ACCESS_TOKEN` retrieved from the previous tutorial.

* Use the `ACCOUNT_ID` retrieved from the first step in this tutorial.

* Use the `TRANSACTION_ID` retrieved from the previous step in this tutorial.

```shell
curl -X GET https://api.aiia.eu/v1/accounts/<ACCOUNT_ID>/transactions/<TRANSACTION_ID> \ 
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
```

#### Response {#response-3}

If the request is successful, the response will look like:

```json
{
  "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",
  "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"
}
```

