Skip to content

Instantly share code, notes, and snippets.

@fancellu
Created June 9, 2023 13:29
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Retrieves a random quote, uses requests, json and pydantic
import requests as requests
from requests import Response
from pydantic import BaseModel
class Quote(BaseModel):
content: str
author: str
response: Response = requests.get('https://api.quotable.io/random')
quote: Quote = Quote.parse_raw(response.text)
print(quote)
requests~=2.31.0
pydantic~=1.10.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment