-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestAPI.py
More file actions
24 lines (19 loc) · 735 Bytes
/
testAPI.py
File metadata and controls
24 lines (19 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests
def fetchFromAPI(query):
'''Fetches response data from API'''
URL = f"https://the-words.herokuapp.com/api/v2/definitions/en-US/entries/{query}"
HEADERS={'Accept': 'application/json'}
response = requests.get(URL, headers=HEADERS)
print(response.status_code)
#print(response.headers)
print(response.text)
def fetchAudioFromAPI(query):
'''Fetches pronunciation data from API'''
URL = f"https://the-words.herokuapp.com/api/v2/audio/en-US/entries/{query}"
HEADERS={'Accept': 'application/json'}
response = requests.get(URL, headers=HEADERS)
print(response.status_code)
#print(response.headers)
print(response.text)
fetchFromAPI("hello")
fetchAudioFromAPI("hello")