Working with the ITunes API

Feb 15, 2017 karen's Blog


This is a guest blog by MIT graduate and former MIT App Inventor team member Aubrey Colter In May 2015, I went to Oakland, CA, to teach an App Inventor workshop to a group of students at Youth Radio. I wanted to teach them about Application Program Interfaces (APIs) to give them a glimpse of how they could extend their apps beyond the available App Inventor components. APIs allow you to access data available on a variety of different sites, such as YouTube, Facebook, and Twitter. These days, most APIs require the programmer to authenticate in some way (usually with a login or token). I knew that setting up the necessary credentials for using an API would take most of our time together. Instead, I decided to search for APIs that did not require authentication. That was how I found the iTunes API. It felt like it had potential to be part of a fun tutorial, so I began searching through the documentation. The first draft of my app called the iTunes API and retrieved information from the database about a musician. However, I knew that the young programmers I would be working with would be uninterested and bored. They could get the same information by reading Wikipedia. It also didnt showcase any of the smartphones capabilities. So I kept searching, until I found the 30-second preview clip API endpoint. When I realized that the App Inventor Sound component could play sound clips from links, I knew I had a great app. I built my app with a very simple interface -- just a search box and a button. Once the button is clicked, the search terms are parsed and sent to the iTunes servers, which returns a list of the artists songs 30-second preview clips. I picked the first one and played it, and I knew that I had something fun.

I took my app to Youth Radio for our workshop, and the programmers had a good time learning about APIs. As Ive iterated on the app for other workshops and open houses for both youth and teachers, everyone has always been so surprised. I love that delight moment! Students are always shocked that my phone can pull up a song by any artist they like (Taylor Swift and Justin Bieber are the favorites).

You can do a lot to extend the iTunes API app once you understand the concept of an API. Ive been really pleased with how it has developed as Ive continued to work on it. I also love hearing positive feedback from teachers and students. I hope youll enjoy it, too! Here is a link to the tutorial.