API Testing
import requests
url = "https://corona-virus-world-and-india-data.p.rapidapi.com/api"
headers = {
"X-RapidAPI-Key": "d484bbc718mshdd2dcfbcf99954bp1222f2jsn6c13602d819c",
"X-RapidAPI-Host": "corona-virus-world-and-india-data.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
#print(response.text)
print("Country Totals")
country1 = input("country")
countries = response.json().get('countries_stat')
for country in countries: # countries is a list
if country["country_name"] == country1: # this filters for USA
for key, value in country.items(): # this finds key, value pairs in country
print(key, value)
import requests
url = "https://forecast9.p.rapidapi.com/"
headers = {
"X-RapidAPI-Key": "d484bbc718mshdd2dcfbcf99954bp1222f2jsn6c13602d819c",
"X-RapidAPI-Host": "forecast9.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
print(response.json())
import requests
url = "https://weatherapi-com.p.rapidapi.com/future.json"
querystring = {"q":"Mexico","dt":"2022-12-25"}
headers = {
"X-RapidAPI-Key": "d484bbc718mshdd2dcfbcf99954bp1222f2jsn6c13602d819c",
"X-RapidAPI-Host": "weatherapi-com.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)