Covid19 RapidAPI Example

"""
Requests is a HTTP library for the Python programming language.
The goal of the project is to make HTTP requests simpler and more human-friendly.
"""
 
import requests
 
url = "https://corona-virus-world-and-india-data.p.rapidapi.com/api"
 
headers = {
   "X-RapidAPI-Key": "561be3d3dcmsh26da5c03e252f9fp1d2d4fjsn25f9e92f38d8",
   "X-RapidAPI-Host": "corona-virus-world-and-india-data.p.rapidapi.com"
}
 
response = requests.request("GET", url, headers=headers)
 
print(response.json)
 
# This code looks for "world data"
print("World Totals")
world = response.json().get('world_total')  # turn response to json() so we can extract "world_total"
for key, value in world.items():  # this finds key, value pairs in country
   print(key, value)
 
print()
 
# This code looks for USA in "countries_stats"
print("Country Totals")
countries = response.json().get('countries_stat')
for country in countries:  # countries is a list
   if country["country_name"] == "USA":  # this filters for USA
       for key, value in country.items():  # this finds key, value pairs in country
           print(key, value)
<bound method Response.json of <Response [200]>>
World Totals
total_cases 509,268,964
new_cases 204,268
total_deaths 6,242,509
new_deaths 630
total_recovered 461,827,849
active_cases 41,198,606
serious_critical 42,510
total_cases_per_1m_population 65,334
deaths_per_1m_population 800.9
statistic_taken_at 2022-04-24 11:18:01

Country Totals
country_name USA
cases 82,649,779
deaths 1,018,316
region 
total_recovered 80,434,925
new_deaths 0
new_cases 0
serious_critical 1,465
active_cases 1,196,538
total_cases_per_1m_population 247,080
deaths_per_1m_population 3,044
total_tests 1,000,275,726
tests_per_1m_population 2,990,303

API For my Project

import requests

url = "https://basketball-data.p.rapidapi.com/tournament/teams"

querystring = {"tournamentId":"89"}

headers = {
	"X-RapidAPI-Key": "b731fee7a5mshf2b6608334c0b07p13bf5fjsn09fcf5df26f4",
	"X-RapidAPI-Host": "basketball-data.p.rapidapi.com"
}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.json())
[{'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'Adelaide 36ers', 'shortName': 'ADE', 'mediumName': 'Ad. 36ers', 'id': 1448}, {'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'Brisbane Bullets', 'shortName': 'BRI', 'mediumName': 'B.Bullets', 'id': 2503}, {'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'Cairns Taipans', 'shortName': 'CTP', 'mediumName': 'C.Taipans', 'id': 1446}, {'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'Illawarra Hawks', 'shortName': 'ILH', 'mediumName': 'I.Hawks', 'id': 1443}, {'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'Melbourne United', 'shortName': 'MEL', 'mediumName': 'Melb.United', 'id': 1445}, {'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'New Zealand Breakers', 'shortName': 'NZB', 'mediumName': 'N.Z.Breakers', 'id': 1441}, {'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'Perth Wildcats', 'shortName': 'PWC', 'mediumName': 'P.Wildcats', 'id': 1442}, {'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'SE Melbourne Phoenix', 'shortName': '', 'mediumName': '', 'id': 3696}, {'isNational': False, 'country': {'name': 'Australia', 'shortName': 'AUS', 'id': 6}, 'name': 'Sydney Kings', 'shortName': 'SDK', 'mediumName': 'S.Kings', 'id': 1444}]