Google Currency API: The Daily REST library entry for Excel and GAScript

Google currency API

Lately for this spot I’ve been selecting APIs that are out of the ordinary, and which allow me to incrementally improve the capability of the REST library. The wrinkle today is that this API does not return valid a jSon. As discussed in a previous post jSon is a subset of javaScript syntax, but some things that are acceptable in javaScript are not part of the jSon specification. If you have a need to check and string for jSon validity, I recommend jsonlint.com.

The Google Currency API is a query by row API, populating each row in a spreadsheet based on a value in a given column. You just name the columns to match any data you want to retrieve and go. Here are the results of a query with a few random currencies. This example can be found in the cDataSet.xlsm and downloaded from here

 

Library entry

In common with an older version of the google wire protocol (which I use to get data from Google Docs), this API returns key/value pairs as key: “value” instead of the valid jSon syntax of  “key” : “value”, so to deal with this I introduced a new option in the library entry syntax ‘wire’. If set to true, then this kind of response will be accepted and dealt with.

And the execution code looks like this
and for Google apps script
The rest library is itself implemented as REST API and can be queried like this.
For more stuff like this, visit the ramblings site or the associated blog. If you have suggestion for particular API,  contact me on our forum
About brucemcp 223 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


12 + 16 =