Using the Songclip API

Screenshot of the application we’ll go through

Written with Flutter

You can find the app itself on github, here. It’s a modification of another repo that uses Flutter, a popular open source, cross-platform mobile development toolkit developed by Google. You’re welcome to install Flutter and run the app locally but it’s not 100% necessary in order to follow this guide.

The section we’ll be working in

Keep your keys safe — meaning, off the device

This app’s purpose is to give a working demonstration on how to use the Songclip API. As such, it’s been kept focused on that goal. One of the ways we keep things simple is by hard-coding the authorization header and API key in the code itself. In practice this is a bad idea. The best approach is to keep that information in a server and use it as a proxy between the device and the Songclip API.

Post requests

Now that we’ve seen what a search request looks like, let’s see how we would report events like play and share. This snippet also comes from api_calls.dart

  1. The sourcePlatform. This is to identify the device type that’s calling the event. In this case it’s an iOS device, and other options include Android and Web.
  2. A sessionId. This identifies the flow through our system and helps track how Songclip is being used in your app — how many searches users are making vs the number of plays and shares, how long the app is open, etc. If an API call doesn’t provide a sessionId we’ll return one to you, which you can then use for the remainder of that session. So for instance, if you call the app open event without a sessionId parameter you’ll get one in the response, and you can use it for the remainder of the user session.
  3. A uniqueId. This is to uniquely identify a user so that metrics can be tracked for future API improvements and to identify which clips and searches are the most popular. The uniqueId can be in any anonymized format you wish — GUIDs are popular — but should not contain any identifiable information such as email addresses or SSNs.
    The uniqueId should remain fixed between app launches for a given device.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Larry Quantz

Larry Quantz

Senior Software Developer at Songclip