You can download this code by clicking the button below.
This code is now available for download.
This function fetches a random quote from the quotable.io API.
Technology Stack : Python, httpx, asyncio
Code Type : Asynchronous function
Code Difficulty : Intermediate
import httpx
import random
def fetch_random_quote():
url = "https://api.quotable.io/random"
async with httpx.AsyncClient() as client:
response = await client.get(url)
quote = response.json()
return quote