Test Brick APIs with cURL

📘

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

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.

📘

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

You can use this JWT/public access token to view the list of institutions currently supported by Brick.

curl https://sandbox.onebrick.io/v1/institution/list \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <public_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 the institution's 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 financial Institution accounts with your application.

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

Step 4: Retrieve Financial Institution account

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
            }
        }
    ]
}

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

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"
        }
     ]
}

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?