Skip to content

Instantly share code, notes, and snippets.

/Python API Secret

Created November 18, 2015 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/76d9f9f058045d092701 to your computer and use it in GitHub Desktop.
Save anonymous/76d9f9f058045d092701 to your computer and use it in GitHub Desktop.
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