Creating apps with the Monetary Authority of Singapore’s new APIs

The Monetary Authority of Singapore recently opened up twelve APIs which will allow app developers to access financial information directly from the banking authority. 

To see how easy these APIs are to use, I tried building a simple web app using the data.

The first step was to review the list of APIs. You can also check the general API documentation which explains how to filter, sort and limit the results. It's also worth reviewing the terms of service which clarify that both commercial and non-commercial usage is allowed.

First I created a simple blank HTML template using the HTML5 Boilerplate and published it to Github at reigndesign/interesting

Reviewing the APIs, I decided to use the API for daily domestic interest rates

The API currently doesn't require any authentication, so it's possible to simply make requests in your browser, for example

https://eservices.mas.gov.sg/api/action/datastore/search.json?resource_id=9a0bf149-308c-4bd2-832d-76c8e6cb47ed&limit=10

will give you 10 records from the "9a0bf149-308c-4bd2-832d-76c8e6cb47ed" resource, which is the daily interest rates.

By adding extra parameters you can filter, for example get data for a specific day

https://eservices.mas.gov.sg/api/action/datastore/search.json?resource_id=9a0bf149-308c-4bd2-832d-76c8e6cb47ed&filters[end_of_day]=2016-11-10

You can also sort, for example the MAS suggest getting the most recent 5 results by timestamp, descending

https://eservices.mas.gov.sg/api/action/datastore/search.json?resource_id=9a0bf149-308c-4bd2-832d-76c8e6cb47ed&limit=5&sort=timestamp%20desc

However, I noticed this didn't work well: it appears multiple days of data get published with identical timestamps, so it's better to sort on end_of_day descending.

Once I'd identified the dataset I wanted, I wrote some simple AJAX code to load the data and render it into a table. The CORS headers have been set correctly, so it's possible to load the data even though its on another domain. The data is located in the data.result.records array, and for each record I pull out the sor_average value, parse it into a float, and multiply by 100 to get a percentage for display.

  1. var interest_end_of_day = '9a0bf149-308c-4bd2-832d-76c8e6cb47ed';
  2. var data = {
  3. resource_id:interest_end_of_day,//the resource id
  4. limit:10,
  5. sort:"end_of_day desc"
  6. };
  7. $.ajax({
  8. url: 'https://eservices.mas.gov.sg/api/action/datastore/search.json',
  9. data:data,
  10. dataType:'json',
  11. success:function(data){
  12. var results = $.map(data.result.records, function(record) {
  13. return {sor:parseFloat(record.sor_average)*100, date:record.end_of_day}
  14. })
  15. $.each(results, function(i,data) {
  16. $("table#rates").append("<tr><td>" + data.date +"</td><td>" + data.sor.toFixed(2) +"%</td></tr>");
  17. });
  18. }
  19. });
  20.  

Here's the end result:

screen-shot-2016-11-11-at-16-16-23

You can see the finished app here or see the source code.

This seems like a great move for Singapore in positioning itself as a fintech hub. In many countries, getting data from government authorities can be painful, but here I was able to build a simple working application in under half an hour.

At ReignDesign we've built fintech apps for companies like BNP Paribas, Standard Chartered and BMW. Get in touch if you'd like to find out more.

Matt Mayer

Matt Mayer is a founder at ReignDesign. Matt is from the UK and was based in Shanghai for ten years. He is now living in Bangkok, Thailand.

2 comments

  1. I’ve did something similar with the european bank’s foreign exhange rate data feed. Nice webapp. It would be an awesome enhancement if you added in search fields and process the dates through date range or simply add a jquery calendar. From my previous experience handling dates from the trading markets i understand the complexity in dealing with non-trade days. The problem comes into play when you need to link the interest rates to specific fields of calculation which maybe dependent on dates or range of dates. I agree with you about the ease of access for these data. The possibility of creating a predictive market analyser would be possible. Coupling this with machine learning and rule base algorithm there might be a chance of making something great!

Leave a Reply

Your email address will not be published. Required fields are marked *