-
Notifications
You must be signed in to change notification settings - Fork 1
/
API_Session.py
54 lines (31 loc) · 915 Bytes
/
API_Session.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## format data as jason
import json
data = response_data.json()
#indent data
print(json.dumps(data, indent=4))
## Store value and store as variable
selected_value = data[0]
## Execute the numbers API fror the number 42
import requests
import json
#create parameterized url
request_URL = "httop;//numberapi.com/42?json"
# Submit request and format output
response_data = requests.get(request_url).json()
print(json.dumps(reponse_data, indent=4))
#select fact
response_data['text']
## House of Requests - TA Exercise
import requests
import json
#Declare request URL to create deck id
create_deck_url = "API url.com"
# Execute create deck url
response_data = requests.get(create_deck_url).json()
response_data
# Parse JSON data
deck_id = response_data['deck_id']
print(deck_id)
#declare draw_cards url and shuffle_deck_url
#use string interpolation to incorporate the deck_id
draw_cards_url = f