-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_practice.py
More file actions
40 lines (29 loc) · 1.05 KB
/
api_practice.py
File metadata and controls
40 lines (29 loc) · 1.05 KB
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
import requests
# base_url = "https://api.github.com/"
# token = "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"
# username = "priyamcoding"
# url = base_url + "user"
# response = requests.get(url, auth= (token, ''))
# print(response)
# print (response.json())
# # we are concatenating user which is an endpoint to the github base_url
# # and if we change that to users, it gives us a list of ALL users
# # updating authenticated user
# url = base_url + "user"
# response = requests.patch(url, auth= (token, ''))
# todo = {"name": "priyamcoding"}
# print(response)
# print (response.json())
# #post method
#working on a public api
response = requests.get("https://www.adoptapet.com/public/apis/pet_list.html")
print(response)
print(response.headers["Content-Type"])
response = requests.post("https://www.adoptapet.com/public/apis/pet_list.html")
print(response)
print(response.headers)
query = {'Lat': '-40.55279', 'Lon': '-121.95272'}
response = requests.get("https://www.google.com/maps", params = query)
print(response)
# print(response.json())
print(response.text)