Hi there, I've used the ability of Mathematica to communicate with other APIs and the FindClusters function to win the Hackathon at the Risk Management Solutions (RMS)
Exceedance Conference 2014. It shows what a great tool for quickly prototyping apps Mathematica is. Please see this short video for details:
Exceedance 2014 RMS(one) API Hackathon Winner
The trickyest part was to make RMS(one) API work with URLFetch, but nothing that trial and error can't solve. For this particular case, I had to use the Apiary interface provided by RMS to fetch an authentication token ( see
THIS ), which is passed as the "Authorization" parameter in the header as shown.
token = URLFetch["https://api.na.rmsone.rms.com/services/v1/tokenService/tokens", "Headers" -> {"Authorization" -> "Basic ZGV2dHJhY2thXEZlbGlwZUQ6RmVsaXBlREAxMjM="}, "Method" -> "POST", "Parameters" -> {"Content-Type" -> "application/json"}];
Once this is done we can create helper functions to communicate with RMS(one) api, passing the token as a header in the way shown. In this case URLFetch retrieves data in "JSON" format, which I convert back to string.
getContracts[pfID_, {offset_, limit_}] := ImportString[URLFetch["https://api.na.rmsone.rms.com/services/v1/ExposureService/portfolios/" <> ToString[pfID] <> "/contracts?offset=" <> ToString[offset] <> "&limit=" <> ToString(*<> "&RiskItemCount>0"*), "Headers" -> {"Authorization" -> tokenP}, "Method" -> "GET"(*, "Parameters"\[Rule]{"Content-Type"\[Rule]"application/json"}*)], "JSON"]
One tricky bit was that the parameter "Parameters" doesn't need to be specified here (it is commented in the code above) but it is required to fetch the authentication token.
Any comments for the code above are mostly welcome. (I'm not sure RMS(one)'s mock server is working at the moment, so the code above will not work)
All the very best,
Felipe