We have hundreds of APIs working overtime to drive a number of our websites. Others provide sources of data for our Social Marketing Platform. While most of the services were designed with our users in mind, this is one API that we built because we wanted the information ourselves. The National Library of Australia Sheet Music collection, available freely from the NLA , includes printed music created by Australians, published in, performed in, or otherwise associated with, Australia. The dataset contains over 11,000 items - including the original scores of Waltzing Matilda and Advance Australia Fair.
The data is made available by the NLA as a mess of XML files that we've ported over to a database and made accessible via a JSON API. We've made the collection searchable by a number of parameters in a number of ways. This article describes basic usage of the API for those of our clients that hold an API key.
Browsing Results
To browse all results, use http://api.beliefmedia.com/nla/music/music.json?apikey=xxxxx
. While the type of search (type=browse
) should normally be defined, this isn't necessary for browsing all results. All results are paginated to a maximum of 30 results.
Music Details
The nlid
key is the ID used to return full details for a particular result. For example, http://api.beliefmedia.com/nla/music/music.json?type=details&id=nla.mus-an7412026&apikey=xxxxx
returns JSON data that unfolds into the following (original Waltzing Matilda Score).
While each of the thumbnail and image links reference the NLA source, we do archive all the images ourselves, and they're all available via a similar local URL (with .jpg extension). They may all be downloaded from within our client area, although NLA's licencing should be understood before using them.
Searching Data
The API supports searching by title, description, subject, and author. To search via freetext, the following should be used:
http://api.beliefmedia.com/nla/music/music.json?type=search&title=waltzing
To search via author (exact match), use the following:
http://api.beliefmedia.com/nla/music/music.json?type=author&creator=ab,+ef
There are numerous other search types available but it's beyond the scope of this article. All data searched via author or text are paginated in the same manner as the first example (for browsing).
Considerations
- We've played with sheet music OCR to port the data into a computer-readable format so it might be played with MIDI (without success). If you've got experience in this area we'd love to hear from you.
- The NLA data isn't structured very well, and we've done our best to clean it up while preserving all field data without alteration.
- Some WordPress shortcodes are to follow. One will take the NLID and construct a container with the music details and a responsive gallery of all pages of music.
- We will be sharing basic API documentation for a number of our APIs over coming weeks. Subscribe to our mailing list or follow us on Facebook for updates.