I chose a random trivia API that outputs random facts.
import requests
url = "https://numbersapi.p.rapidapi.com/random/trivia"
querystring = {"min":"10","max":"20","fragment":"true","json":"true"}
headers = {
"X-RapidAPI-Key": "217acfa59emsh9a56b5c7ec9c672p11520bjsnbe23d137f1c8",
"X-RapidAPI-Host": "numbersapi.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
I did coin flip API, here which flips a coin and outputs whether is head or tails.
import requests
url = "https://coin-flip1.p.rapidapi.com/headstails"
headers = {
"X-RapidAPI-Key": "217acfa59emsh9a56b5c7ec9c672p11520bjsnbe23d137f1c8",
"X-RapidAPI-Host": "coin-flip1.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
print(response.text)