/ Hacks

Decrypting Gaana's undocumented API

This weekend has been fun! I do a lot of hacks around Gaana.com! But, now I needed to get Metadata of the tracks I listen to. Here is a quick explanation on how I was able to put together an AWESOME personalized media station for myself!

Here is an interesting API calls obtained from proxying an android app using Charles Proxy.

Get playlist details

curl XXXX-various-headers-here --compressed 'https://api.gaana.com/index.php?type=playlist&subtype=playlist_detail&playlist_id=2957847&playlist_type=playlist&token=XXXXX'

I suspected that the above code should be successfuly using a more simpler calls and my suspicion turned out to be right!

curl 'https://api.gaana.com/index.php?type=playlist&subtype=playlist_detail&playlist_id=2957847&playlist_type=playlist'

Now, that for a random playlist android app request I tried to hack into and issuing the curl command from my Mac worked just fine!

So, now I need details about my own custom playlist. Plugging in the playlist_id should cause the above curl command to get all details. But, how do I get my playlist id???

Lets proxy a chrome on Mac request through Charles Proxy!

Inspecting Ajax request from Charles proxy from the Chrome browser on Mac reveals Suji Gym Playlist id to be 7421911

Charles Proxy inspection of browser request

Gathering the data now is a breeze using the curl command below:

curl 'https://api.gaana.com/index.php?type=playlist&subtype=playlist_detail&playlist_id=7421911&playlist_type=playlist'

This returns the json of the playlist. Getting just the trackid and trackname is fun using jq!

Just the track ids:
curl 'https://api.gaana.com/index.php?type=playlist&subtype=playlist_detail&playlist_id=7421911&playlist_type=playlist' | jq '.tracks[] | .track_id' > sujis-tracks.txt

The trackids and trackname in a neat json represetation!

curl 'https://api.gaana.com/index.php?type=playlist&subtype=playlist_detail&playlist_id=7421911&playlist_type=playlist' | jq '.tracks[] | {trackId: .track_id, title: .track_title}'

Pass it to an output file and you have everything you need!

curl 'https://api.gaana.com/index.php?type=playlist&subtype=playlist_detail&playlist_id=7421911&playlist_type=playlist' | jq '.tracks[] | {trackId: .track_id, title: .track_title}' > sujis-songs.json

Parse gaana json using jq