Skip to content

Instantly share code, notes, and snippets.

@zallarak
Created January 14, 2013 21:58
Show Gist options
  • Select an option

  • Save zallarak/4533914 to your computer and use it in GitHub Desktop.

Select an option

Save zallarak/4533914 to your computer and use it in GitHub Desktop.
simple locu api wrapper
LOCU_API_KEY = 'xxx'
def get_response(params, api_category='venue', api_type='search'):
"""
Takes a dictionary of params and queries the Locu API, returns
a requests.response object.
"""
def get_api_url(params):
base = 'http://api.locu.com/v1_0/{0}/{1}/?api_key={3}&'.format(
api_category,
api_type,
LOCU_API_KEY)
return ''.join([base, urllib.urlencode(params)])
try:
r = requests.get(get_api_url(params))
except Exception as e:
r = False
return r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment