-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.py
36 lines (27 loc) · 801 Bytes
/
api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
import json
from pprint import pprint
import server
import os
def get_therapist_info(city):
textChoice = "Therapist"
API_key = os.environ['YELP_API']
client_id = 'Your Client ID'
ENDPOINT = 'https://api.yelp.com/v3/businesses/search'
HEADERS = {'Authorization': f'Bearer {API_key}'}
PARAMETERS = {
'term' : textChoice,
'limit' : 10,
'location' : city,
'radius' : 10000
}
response = requests.get(url = ENDPOINT, params = PARAMETERS, headers = HEADERS)
data = response.json()
provider_list=[]
for place in data['businesses']:
provider_dict={}
provider_dict['name']=(place['name'])
provider_dict['other']=( place['phone'])
provider_dict['address']=(place['location']['display_address'])
provider_list.append(provider_dict)
return provider_list