manniru
10/21/2014 - 8:07 AM

GetJsonFromUrl.py

# https://developer.decibel.net/sample-code-rest-python

import urllib2
import time
import datetime

# Set the request authentication headers
timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y%m%d %H:%M:%S')
headers = {'DecibelAppID': '<Your Application ID>',
           'DecibelAppKey': '<Your Application Key>',
           'DecibelTimestamp': timestamp}

# Send the GET request
url = 'http://api.decibel.net/v1/Albums/?artist=miles%20davis&format=json'      
req = urllib2.Request(url, None, headers)

# Read the response
resp = urllib2.urlopen(req).read()