Snippets

Lars Basic GeniusAPI GET request (search lyrics)

You are viewing an old version of this snippet. View the current version.
Revised by Lars b92f91d
import httplib, urllib, json,  random, sys

def getData(auth_string):
    conn = httplib.HTTPConnection("api.genius.com")
    request_uri = "/search/lyrics?q=You%20only%20get%20one%20shot" 
    headersMap = {
            "User-Agent": "CompuServe Classic/1.22",
            "Accept": "application/json",
            "Authorization": "Bearer " + auth_string
    }
    conn.request("GET", request_uri, headers=headersMap)
    response = conn.getresponse()
    ### Output the HTTP status code and reason text...
    print response.status, response.reason
    data = response.read()
    result = json.loads(data)

    print json.dumps(result, indent=4, sort_keys=True)

getData("<Auth token here>")
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.