Querying Data
Now you have made a connection to a financial institution you are able to start querying the API for its financial data.
Get Accounts
Lets start by getting the accounts of your user.
You are going to make a request to our resource server https://api.moneyhub.co.uk/v2.0 at GET /accounts
For this you will need to pass in an access token as the bearer auth header. You can obtain this token by making a client_credentials
grant request to the identity token endpoint.
To get our new client-credentials token you will need to POST /oidc/token
to our identity endpoint: https://identity.moneyhub.co.uk
This token also needs scopes based on the data you are querying so for our example below we will use accounts:read
curl --location --request POST 'https://identity.moneyhub.co.uk/oidc/token' \
--header 'Content-T: application/x-www-form-urlencoded' \
--form 'scope="accounts:read"' \
--form 'sub="{User ID of the user you wish to query the accounts of}"' \
--form 'grant_type="client_credentials"' \
--form 'client_assertion_type="urn:ietf:params:oauth:client-assertion-type:jwt-bearer"' \
--form 'client_assertion= {Your JWT}'
Once successful, you should receive this response:
{
"access_token": "The client credentials access token",
"expires_at": "The expiry of this token",
"scope": "The scopes requested",
"token_type": "The type of token this is (client credentials)"
}
Now you have a token, with the ability to read accounts! Let's do this now.
curl --location --request GET 'https://api.moneyhub.co.uk/v2.0/accounts' \
--header 'Authorization: {access_token}' \
Customising The Query
Many of our endpoints allow extra customisation via query parameters. For instance
offset
&limit
to shape the amount of data you receive. To see a breakdown of all our API endpoints and their customisation options visit our docs here: API Docs
You should get back some data that looks like this:
{
"data": [
{
"id": "d372d09b-f50a-4114-9c83-687828fa8ac2",
"dateAdded": "2020-07-27T14:33:44+00:00",
"dateModified": "2020-07-27T14:33:44+00:00",
"accountName": "Joint Account",
"type": "cash:current",
"providerName": "Lloyds",
"providerId": "DEMO",
"providerReference": "demo",
"connectionId": "DEMO:666",
"accountHolderName": "Robert Cantu",
"balance": {
"date": "2020-07-27",
"amount": {
"value": 802323,
"currency": "GBP"
}
},
"currency": "GBP",
"details": {
"AER": 0,
"overdraftLimit": 0,
"sortCodeAccountNumber": "30949301273345"
},
"transactionData": {
"count": 218,
"earliestDate": "2019-08-02",
"lastDate": "2020-07-27"
}
}
]
}
That's it! You have just queried the main API for its data. There are many endpoints that handle lots of different types of data, this is just the tip of the iceberg.
Updated 9 months ago
You can go back to the other use cases, or dive into our wider documentation.