Create a gist now

Instantly share code, notes, and snippets.

anonymous /Python API Secret
Created Nov 18, 2015

What would you like to do?
import urllib2
import json
"""
Send API call to metanumber server (designated via the URL variable). The equation is appended (per the parameters of the API call), and the result is returned / parsed.
"""
def makeAPICall(equation):
url = 'http://tyson.rci.sc.edu/metanumber/api/v1.0/engine/' #MN server address
equation = equation.replace("/", "|") #parse equation for division
requestURL = url + equation #concatenate URL and equation for full API call
returnValue = json.loads(urllib2.urlopen(requestURL).read()) #get return value
return returnValue['result'] #parse and print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment