Decrypting Gaana's undocumented API

. 2 min read

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


Tags

AWS Analytics Antifragile Apache Spark Apple Apps Arbitrage Automation Awesome BBMP Bangalore Black Swan Bonds Boonex Bootstrap Brokerage Charges CFPB CMS CSS Calypso Camelot Capital Markets Charts Chirp Choropleth Chrome Code Igniter Collections Containerization Converters Cycling DalalBeat Data Analytics Data Journalism Data Mining Data Munging Data Privacy Data Science Databases Debt Design Design Stock DesignStock Diet Django Docker Document Processing Dropbox Electron Electronics Entertainment Entrepreneurship Exercise FFMPEG Facebook Finance Fire TV Stick Fitness Forerunner From-The-News Fun Futures Gaana Garmin General Geocoding Getting Started Ghost Google APIs GraphicsMagick HHVM HTTPS Hackathon Hacks Hardware Health House Keeping Housing IBM BlueMix IBrokers IPinfo Ideas Image Conversion Image Processing Infographics Interactive Brokers Internet Investing IoT Legal Lets Encrypt Mac Machine Learning Mailbox app Mapbox Markdown Marketing Meteor Mockups MongoDB Mortgages Movies Music MyPad MySQL Nativefier Nature Netflix Newsletters Nginx Node.js Notes OCR OSX Open Source OpenCPU Options PDF PHP Pebble Peloton Personal Photography Picture Platforms Plex Portable Apps Productivity Property Tax PyroCMS Quantitative Finance R-Project Random Raspberry Pi Research Resources Reticulate Robot S3 SQLite STT Scraping Security Server Shell Shiny Side Project Sikuli Speech Recognition Spider Pro Spinning Spotify Startup Resources Startups Strategy Sublime Text System Monitoring Tax Terminal Tips To Do Tools Torrent Trading Trends Troubleshooting USElection2016 Ubuntu Unix Valuations Video Conversion Visualization Wagtail Wearables Weekend Fun WhatsApp Wordpress anaconda annie bash catalina cv2 daily coding dailycoding data.table debugging devtools downloader e-Signatures ggplot git go google maps hat-tip iOS iPad iPhone iTunes javascript jupyter logging macos numpy opencv optionality plotly python rstats videos youtube