API Exploration
Experimenting with APIs
| Data Navigation Bar | Covid19 API | Love Calculator API | 
Notes
- RapidAPI, you will select Python Requests type of code to work with your Notebook
 - The url is the endpoint to which the API is directed
 - The headers is a dictionary data structure to send special messaging to the endpoint
 - The requests.request() python function is used to send a request and retrieve their responses
 - The response variable receives result of of the request in JSON text
 - Replace key with personal key to access the API
 - Remember to subscribe to the API to access
 
My Process
I explored the RapidAPI a ton, and I played around with many of the APIs. I found a ton of practical ones, as well as fun ones, and I have our group's final project in mind when I search through the APIs. There are a lot that I found that we could potentially utilize, such as a gratitude message generator, a mood tracker, and mental health stats. Those are some practical ones, but this fun one below was my favorite that I tried out.
"""
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
"""
RapidAPI is the world's largest API Marketplace. 
Developers use Rapid API to discover and connect to thousands of APIs. 
"""
url = "https://corona-virus-world-and-india-data.p.rapidapi.com/api"
headers = {
    'x-rapidapi-key': "dec069b877msh0d9d0827664078cp1a18fajsn2afac35ae063",
    'x-rapidapi-host': "corona-virus-world-and-india-data.p.rapidapi.com"
}
# Request Covid Data
response = requests.request("GET", url, headers=headers)
# print(response.text)  # uncomment this line to see raw data
# 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)
import requests
url = "https://love-calculator.p.rapidapi.com/getPercentage"
querystring = {"sname":"Annika Liao","fname":"Alex Turner"}
headers = {
	"X-RapidAPI-Key": "26fd9549c8msh64e7e2f5ac3301fp18259djsn17ca48c66a6a",
	"X-RapidAPI-Host": "love-calculator.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)