Mondo Bank has recently moved into public Beta, sending out 1,000 cards to trial customers each week. I received my Beta card a few days ago, and have been using it ever since. This blog post takes a quick look at the Mondo API and how I used it to automate expense claims!
Until very recently, banking in the UK has been a monopoly, with the same small collection of banks occupying the high street. Five years ago Metro Bank received the first new banking licence in over 100 years, since then, more than a dozen new licences have been granted giving rise to the ‘Challenger Bank’. These new banks plan to shake up banking by providing a better, more modern service, whilst the incumbents struggle under the weight of their legacy infrastructure.
One challenger that stands out from the crowd is Mondo, which feels more like a start-up than a bank. Their developers present talks at conferences describing their microservice architecture built using Go, they’ve run hackathons and of course have a public API. They are not letting the fact that they don’t have a banking licence get in the way of testing their product and building their brand!
It’s no wonder that Mondo is very popular among developers.
As you’d expect from Mondo, the beta process is all managed within the app. On sign up you are added to a queue, which shows your position in realtime. Sharing the Beta link helps you move up the queue, jumping 4,000 places on each sign up. Once you reach the top thousand, you’re part of the beta and your card is sent out - with some cute in-app animations showing its progress:
Their paper-based correspondence is top-quality too, with your card arriving in a cool purple envelope, with a hashtag encouraging you to share that you’ve #GotMondo:
Image courtesy of @ChiericiAlberto
I received my card just before heading off to London for a few days on business, giving me a great opportunity to try it out!
Another motivation for getting hold of a Beta card was to try out their API. I was thinking of perhaps turning my transactions into music, but that idea has already been taken (by the Singing Bank), so instead I thought I’d go for something more mundane and practical, I’d see if I could automate my expense claims process before I returned from London.
The Mondo API is very well documented, furthermore, there is quite an active Slack channel where the Mondo team are on hand to provide assistance. This enabled me to get up and running very quickly.
In order to access a customer’s account information, OAuth 2.0 is used to grant your application access. The first step in this process is to create an OAuth client via the Mondo Developer Console. This client will be given an id and a ‘secret’, both of which are used in the login process:
To automate my expenses, I created a node / express app which obtains transaction data from the Mondo API.
In order to protect the client id and secret, these are passed to the node app via the command line, using minimist as the parser. If the user hasn’t already logged in, the first step is to direct them to the Mondo-hosted login page:
The login URL contains the client id, together with a redirect URL, which in this case is simply
localhost because I haven’t deployed this app to a live environment yet. This directs the user to the following login page:
Once they enter their email address, they will be a sent an email which contains a link that redirects them back to your application. The redirect querystring contains a
code property which is a temporary authorization code which the app next exchanges for an access token.
The code below uses the request-promise library, which provides a simplified HTTP client with a promise API.
The following makes the authorization token request, which provides the client id and redirect URL once again, but this time also adds the client secret and the authorization code.
The successful response to this request contains the access token, which this application stores in the session, completing the authentication process.
Subsequent requests need to have an
Authorization header that provides the access token. With the current API you can access an account list, balance and transaction items. You can also provide data that is persisted, including transaction annotations, attachments and webhooks. The current API already provides a lot of scope for creating interesting integrations, and I’m sure it will continue to grow.
For the purposes of automating expenses I simply want to obtain my account identifier, followed by the account balance and transactions. In order to coordinate the requests I used the popular Q ‘promise’ library.
The Mondo app automatically categorises purchases based on merchant data, and does include an ‘expenses’ category which you can manually add transaction to. However, I wanted to keep the automatic categorisation, so instead opted to mark transactions with an
#expenses keyword in the notes.
The code below is really quite self explanatory, it performs the various API requests, assembling a data object which contains the aggregated results, which are provided to the
response.render method. This uses a simple ejs template to render the transactions as HTML.
I’ll not bore you with the details of the template, it’s pretty straightforward. Here’s the results of my expenses for that two-day trip to London:
I also created a ‘view’ which renders the data as CSV so that it can be pasted directly into our company’s Excel-based expenses sheets.
The transactions request in the code above includes
expand=merchant within the querystring causing the
merchant property in the response to be expanded for each transaction. This includes a wealth of information - this is the purchase I made at Pret A Manger (with a few field values removed):
You not only get address, logo, geolocation and category, but also Twitter, Foursquare and Google identifiers. You can also add attachments to purchases via the app, which are also included in this metadata. In this case, I’ve photographed receipts so that I can add them to the expense claim.
The Mondo developer and user experience are going to prove a real hit for developers. If they manage to continue this innovative and friendly feel once they become a ‘proper’ bank they’ll be on to a winner. I’m happy to report that I managed to create my expenses app in just a few hours on the train back home to Newcastle, with my first automated claim ready to submit.
Now all I need to do is persuade our finance team to expose an API, then I’ll be able to register a webhook with Mondo that ‘pushes’ my tagged transactions, allowing me to submit expenses in real time!
You can find the code for my example app on GitHub.
Regards, Colin E.