Random Quote Fetcher using Requests Library

  • Share this:

Code introduction


The function uses the Requests library to fetch a random quote from https://api.quotable.io/random and returns the content of the quote.


Technology Stack : Requests, JSON

Code Type : Function

Code Difficulty : Beginner


                
                    
import requests
import random

def get_random_quote():
    response = requests.get("https://api.quotable.io/random")
    data = response.json()
    return data["content"]                
              
Tags: