Random Quote Fetcher from quotable.io

  • Share this:

Code introduction


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