Tutorial: Connect Financial Institution A/C & view Transactions

📘

In this section, you will learn how to connect with a financial institution and access your first financial data like accounts, balance and transactions.

Brick is currently offering two environments:

  • Sandbox, a sandbox environment with test data perfect for test and development phases.
  • Production, a live environment used in production with real connections to institutions.

To generate your keys for each environment, have a look to our guide to get your Brick API keys or Sign Up now!

You follow this tutorial along side a video tutorial we made for better understanding.

📘

In the following examples we will use the sandbox environment.
Change the base URL to https://api.onebrick.io for each example to switch to production.

Step 1: Generate a JWT bearer token (Public access token)

Use your Sandbox API keys viz. a ClientID & ClientSecret with the generate public token api to get a JWT((JSON Web Token). This JWT or what we call a public access token can be used to launch the Brick widget and access institution list.

curl -u Client ID:Client Secret https://sandbox.onebrick.io/v1/auth/token
{
    "status": 200,
    "message": "OK",
    "data": {
        "access_token": "public-sandbox-b70bcf83-87a1-4f2c-8f2a-16d48021413a"
    }
}

Response Parameter

Key Parameter

Data Type

Description

access_token

string

Token that is required to connect Brick API

Step 2: List all supported institutions ( Optional )

You can use this JWT/public access token to view the list of institutions currently supported by Brick or jump to Step 3 directly to try the Brick Front End Widget and connect a Financial Institution account to view its data.

curl https://sandbox.onebrick.io/v1/institution/list
  -H 'Content-Type: application/json' 
  -H 'Authorization: Bearer JWT-public-access-token'

Where, [JWT-public-access-token] is the public access token/JWT generated in the previous step which needs to be passed as the Bearer token in the Authorization header.

The api responds with institutions list currently supported by Brick.

Response Parameter

Key Parameter

Data Type

Description

id

integer

Identification number of the Institution

name

string

Institution name

bank_code

string

Institution code

country_code

string

Country code for the institution

country_name

string

Country name of the institution

primary_color

string

Primary color of the institution for UI color

logo

string

Logo of the institution

createdAt

string

Date and time of the institution is up

updatedAt

string

Date and time of the institution is updated

channels - id

integer

Institution identification number

channels - institution_id

integer

Institution identification number

channels - name

string

Institution banking name (e.g. Internet banking or Mobile banking)

channels - type

string

Institution type (e.g. Individual or Corporate)

channel - status

string

Status of the Financial institution (e.g Active or Inactive)

channels - createdAt

string

Date and time of the institution is up

channels - updatedAt

string

Date and time of the institution is updated

Step 3: Launch Brick Widget

Use the JWT/public-access-token to launch the brick widget in your application and let your users connect their Financial Institution accounts with your application.
To launch the brick UI widget you need to construct the URL in the following format-
https://cdn.onebrick.io/sandbox-widget/v1/?accessToken=public-sandbox-access-token

📘

Notice that the URL above is a newer version ( V1 ) of our Brick Widget that contained a new feature inside comparing to the old version. Currently, we still offer you our old Brick Widget where your end-user can only connect a single account at a time ( https://cdn.onebrick.io/sandbox-widget/?accessToken=public-sandbox-access-token ) until further notice.

Therefore, we encourage you to integrate and experienced our newest feature on Brick Widget as soon as possible where your end-user have the ability to connect multiple accounts/institutions in single flow.

P.S : This feature would be very helpful for you to have as much information from the connected accounts/institutions from your end-users.

There are some optional parameters that can be added to the above URL for customizations which can be seen here.

Read the Brick Widget Section to see in-depth integration steps.

Step 4: Retrieve Financial Institution accounts

Retrieve List of all accounts for this user

Using the previously created user-access-token in Step 3, we can now retrieve the information about different Financial Institution accounts connected by this user.

curl https://sandbox.onebrick.io/v1/account/list 
  -H 'Content-Type: application/json' 
  -H 'Authorization: Bearer user-access-token'

Where [user-access-token] is the access token generated after successful Financial Institution connection through the widget which needs to be passed as the Bearer token in the Authorization header.

The API responds with accounts associated with the user who logged in using the Brick widget.

{
    "status": 200,
    "message": "OK",
    "data": [
        {
            "accountId": "UarXg4ad/81344wJF8xthY==",
            "accountHolder": "JOHN DOE",
            "accountNumber": "1551110757891",
            "balances": {
                "available":22130.0,
                "current": 22130.0
            }
        },
        {
            "accountId": "ZUTBeQcl2FTqNUwcVDuRFF==",
            "accountHolder": "JOHN DOE",
            "accountNumber": "1234567890123",
            "balances": {
                "available": 320554.15,
                "current": 320554.15
            }
        }
    ]
}

Response Parameter

Key Parameter

Data Type

Description

accountId

string

Account Identification number from end-user's Financial Institution account

accountHolder

string

Name of the end-user's Financial Institution account holder

accountNumber

string

Account number from end-user's Financial Institution account

balances - available

float

End-user's balance amount that is available to use

balances - current

float

End-user's balance amount that includes "balances-available" and "on-hold amount"

Retrieve details of a particular Financial Institution account

Using the accountId retrieved from the previous API- accounts list, you can get in-depth details about the account include any identifying information that's available on the account.

curl https://sandbox.onebrick.io/v1/account/detail?accountId=accountId 
  -H 'Content-Type: application/json' 
  -H 'Authorization: Bearer user-access-token'

Where [user-access-token] is the access token generated after successful Financial Institution connection through the widget which needs to be passed as the Bearer token in the Authorization header. And accountId is the identification of the account for which you want the details.

The API responds with details of the account associated with the accountId.

{
    "status": 200,
    "message": "OK",
    "data": {
        "accountId": "S8vzhyw3owDtYDOB87va==",
        "accountHolder": "John Doe",
        "accountNumber": "987-0675-789",
        "balances": {
            "available": 7500000.0,
            "current": 7500000.0
        }
    }
}

Response Parameter

Key Parameter

Data Type

Description

accountId

string

Account Identification number from end-user's Financial Institution account

accountHolder

string

Name of the end-user's Financial Institution account holder

accountNumber

string

Account number from end-user's Financial Institution account

balances - available

float

End-user's balance amount that is available to use

balances - current

float

End-user's balance amount that includes "balances-available" and "on-hold amount"

Where, [user-access-token] is the access token generated after successful Financial Institution connection through the widget which needs to be passed as the Bearer token in the Authorization header. And accountId is the identification of the account for which you want the details.

Step 5: Retrieve transactions

Using the previously generated user-access-token, we can now retrieve all transactions for this user from all his Financial Institution accounts under the login used with the brick widget.

curl https://sandbox.onebrick.io/v1/transaction/list?from=from&to=to 
  -H 'Content-Type: application/json' 
  -H 'Authorization: Bearer user-access-token'

Where, [user-access-token] is the access token generated after successful Financial Institution connection through the widget which needs to be passed as the Bearer token in the Authorization header.

The api responds with rich transaction data of all the accounts associated with the user under his login.

{
    "status": 200,
    "message": "OK",
    "data": [
        {
            "id": 9744,
            "account_id": "jwYhjuy4tQZx8sZj3oBrg9fSqvzsR41F==",
            "category_id": 24,
            "subcategory_id": 141,
            "merchant_id": 8,
            "location_country_id": 0,
            "location_city_id": 0,
            "outlet_outlet_id": 0,
            "amount": 600000.0,
            "date": "2020-06-29",
            "description": "ATM-MP SA CWD XMD S1AW1MJK /7774759936/ATM-RCOASIAAFRK 4616993200225278 RCOASIAAFRK",
            "status": "CONFIRMED",
            "direction": "out"
        },
        {
            "id": 9743,
            "account_id": "jwYhjuy4tQZx8sZj3oBrg9fSqvzsR41F==",
            "category_id": 22,
            "subcategory_id": 129,
            "merchant_id": 0,
            "location_country_id": 0,
            "location_city_id": 0,
            "outlet_outlet_id": 0,
            "amount": 1000.0,
            "date": "2020-06-29",
            "description": "CA/SA UBP DR/CR-ATM UBP60116073701FFFFFF085755130021 50000 S1AW1MJK /7774759939/ATM-RCOASIAAFRK P085755130021",
            "status": "CONFIRMED",
            "direction": "out"
        }
     ]
}

Response Parameter

Key Parameter

Data Type

Description

id

integer

Identification number of the transaction

account_id

string

End-user account number that is used to do the transaction

category_id

integer

Category identification number of the transaction

subcategory_id

integer

Subcategory identification number of the transaction

merchant_id

integer

Merchant identification number of the transaction

location_country_id

integer

Country identification number of the merchant

location_city_id

integer

City identification number of the merchant

outlet_outlet_id

integer

Outlet identification number of the merchant

amount

float

Amount of the transaction

date

string

Date of the transaction

description

string

description detail of the transaction

status

string

Status of the transaction (Confirm or Pending)

direction

string

Direction of the transaction (in or out)

Conclusion

Using this step by step guide you have been able to get a first preview on Brick's API and how to integrate Brick in your website or application


Did this page help you?