Python, RapidAPI Terms

APIs and tooling like Jupyter docs allows many opportunities in fields like Data Science. As more and more developers use APIs, they build standards in how you setup a client, send requests and receive information...

Quote API

To begin the API journey. You need to find an API provider.

  • I used a motivational quote API Motivation Quote Data- This API pulls random motivational quotes from a website -It will prompt you to rate the quote from 1-10 each time it generates a quote
import requests

url = "https://motivational-quotes1.p.rapidapi.com/motivation"

payload = {
	"key1": "value",
	"key2": "value"
}
headers = {
	"content-type": "application/json",
	"X-RapidAPI-Key": "97cada0567msh30f120b09c87306p148cacjsn5a7d8d05dc40",
	"X-RapidAPI-Host": "motivational-quotes1.p.rapidapi.com"
}

response = requests.request("POST", url, json=payload, headers=headers)
rating =int(input("Please rate the quote on a scale from 1 to 10"))
if rating <= 10 and rating >= 1:
	print("You rated this quote", rating, "out of 10")
else:
	print("Please have a rating between 1 and 10")

print(response.text)
You rated this quote 10 out of 10
"Something opens our wings. Something makes boredom and hurt disappear. Someone fills the cup in front of us: We taste only sacredness."
-Rumi

Go deeper into APIs

Web Development vs Jupyter Notebook. A notebook is certainly a great place to start. But, for your end of Trimester project we want you to build the skill to reference and use APIs within your Project. Here are some resources to get you started with this journey.

Hacks

Find and use an API as part of your project. An API and a little coding logic will be a big step toward getting meaningful data for a project. There are many API providers, find one that might work for your project to complete this hack. When picking an API you are looking for something that will work with either JavaScript Fetch or Python Request. Here are some samples, these are not qualified in any way.

Show API and format results in either Web Page or Jupyter Notebook. Ultimately, I will expect that we do APIs in backend (Python/Flask). However, for this Hack you can pick your preference. We will discuss pros and cons in next API tech talk.