The Itunes API is very nice. You can find details on it at ITunes API
I thought I may as well add an Apps Script wrapper library to it, since it can provide a wealth of test data to play around with, and it may be useful to some.
The API is open and public, so no need for API keys or anything.
You'll need the cITunesAPI library (or you can get in from github)
Then you can do this
var itunes = new cITunesAPI.ITunesAPI();
I've implemented two kinds of retrieval methods
The are many parameters, documented in the itunes api page, so I'll show a selection of examples here to see how you can invoke them with the Apps Script library. The format of the results object is the same as I use for many of the libraries, and looks like this
so check result.success, and if all is well you can use result.data.
All of these lookups can take multiple ids. Just specifify them in a list
Any API parameters can be added to an array as the second argument to the lookup method. Dont encode them - the library will take care of that.
The searchTerm method takes a simple text search, in addition to any of the API optional parameters
The default limit on searches is 50, and the maximum is 200. There is no way of pagination if you need to get back more
Here's an example of the results
If you want to dump that to a sheet, you may not want all of it. Here's a handy pattern to selectively write out some fields
Which gives you something like this.
For more like this, see Google Apps Scripts snippets. Why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.
You want to learn Google Apps Script?
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, available All formats are available now from O'Reilly,Amazon and all good bookshops. You can also read a preview on O'Reilly.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Scripts snippets >