Get Started

📘

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 can get started along side video tutorials we made for better understanding. We have videos in both English and Bahasa languages.

📘

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

This should give you a JWT/public access token that is only valid for next 30 minutes and which can be used to launch the Brick Widget and access institution list.

{
    "status": 200,
    "message": "OK",
    "data": {
        "access_token": "public-sandbox-b70bcf83-87a1-4f2c-8f2a-16d48021413a"
    }
}

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 bank account to view it's 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.

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 bank 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

📘

Important Notes :

Notice that the URL above is a newer version ( V1 ) that contain a new feature inside compare to the previous one. Therefore, we encourage you to upgrade and integrate with the newest URL to experience the new Brick Widget that we offer. For more information refer to Brick Widget Section

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

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

Step 4: Retrieve bank 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 bank 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 bank 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
            }
        }
    ]
}

Retrieve details of a particular bank account

Using the accountId retrieved from previous api- accounts list, you can get in-depth details about the account include any identity 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 bank connection through the widget which needs to be passed as the Bearer token in the Authorization header. And accountId is the identification of 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
        }
    }
}

Where, [user-access-token] is the access token generated after successful bank connection through the widget which needs to be passed as the Bearer token in the Authorization header. And accountId is the identification of 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 bank 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 bank 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"
        }
     ]
}

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


What’s Next
Did this page help you?