API Wrappers API Wrappers: Python 2.x

The following Python 2 wrapper can communicate with the API. It was submitted by Terry Moore. You can download the API python 2 wrapper for use.

#Query API via Python 2.71.

import urllib, json, sys


apikey = ''
format = 'json'
apiver = '2.0'
method = 'pnet.shows.setlists.latest'

#Build parameters to send via GET to api.js
params = urllib.urlencode({

#Attempt to open a connection and get the JSON formatted data
  f = urllib.urlopen(url + endpoint + "?%s" % params)

#Do this for invalid URL
except IOError:
  print 'Error: Unable to connect. Invalid URL. '

#Get the response code
rsp = f.getcode()

#If the HTTP response is 200 (OK) then proceed
if rsp == 200:

  #Read the data
  data =

  #Decode the data as JSON
  decoded = json.loads(data)

  #Print the Decoded JSON
  print 'DECODED: ', decoded

  #Print an individual JSON Record
  print 'GET INDIVIDUAL RECORD: ', decoded[0]['showdate']

  #Do this if the not an HTTP response of 200
  print 'Error - HTTP Response Code: ',  rsp

#close the connection

This should provide you the infrastructure to communicate with the API using any method.

Support & Mbird is a non-commercial project run by Phish fans and for Phish fans under the auspices of the all-volunteer, non-profit Mockingbird Foundation.

This project serves to compile, preserve, and protect encyclopedic information about Phish and their music.

Credits | Terms Of Use | Legal | DMCA

© 1990-2020  The Mockingbird Foundation, Inc. | Hosted by Linode