Created
March 30, 2016 22:41
-
-
Save gupul2k/d7064c5d0946e6ae33cee3ce4aa87bf0 to your computer and use it in GitHub Desktop.
Python to Connect LocuAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import urllib2 | |
import json | |
locu_api = 'YOUR_API_KEY' | |
#final_url = 'https://api.locu.com/v1_0/venue/search/?locality=Newport%20Beach&api_key=YOUR_API_KEY' | |
def locu_search(query): | |
api_key= locu_api | |
url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key | |
locality = query.replace(' ', '%20') | |
final_url = url + "&locality=" + locality + "&category=restaurant" | |
json_obj = urllib2.urlopen(final_url) | |
data = json.load(json_obj) | |
for item in data['objects']: | |
print item['name'], item['phone'] | |
Outcome: | |
locu_search('Boston') | |
Singh's Roti Shop (617) 282-7977 | |
Nunzio's (617) 723-4321 | |
Chipotle Mexican Grill (857) 244-6579 | |
Siam Bistro (617) 210-7953 | |
Taste of the Town (617) 443-4574 | |
Boston Salad & Provision (617) 541-9040 | |
Cafe 1010 (617) 427-0727 | |
The Brasserie Pizza Pasta None | |
Morse Fish Company (617) 262-9375 | |
Peach Farm (617) 482-1116 | |
Bangkok Express (617) 723-2758 | |
Nick's Pizza And Seafood (617) 282-8805 | |
Boston Beer Garden (617) 269-0990 | |
Millenium Restaurant & Grill (617) 522-0505 | |
Metro Cafe (617) 451-0890 | |
Au Bon Pain (617) 428-9476 | |
Longwood Galleria (617) 566-5204 | |
Barrington Coffee Roasting Company (857) 277-1914 | |
Papagayo (617) 423-1000 | |
Walsh Seafoood (617) 330-6964 | |
West end pizza (617) 557-0009 | |
Host International (617) 634-6000 | |
Volle Nolle (617) 523-0003 | |
Itadaki (617) 267-0840 | |
Katrina's Pizza (617) 442-2330 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment