File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ This file fetches quotes from the " ZenQuotes API ".
3
+ It does not require any API key as it uses free tier.
4
+
5
+ For more details and premium features visit:
6
+ https://zenquotes.io/
7
+ """
8
+
9
+ import pprint
10
+
11
+ import requests
12
+
13
+
14
+ def quote_of_the_day () -> list :
15
+ API_ENDPOINT_URL = "https://zenquotes.io/api/today/"
16
+ return requests .get (API_ENDPOINT_URL ).json ()
17
+
18
+
19
+ def random_quotes () -> list :
20
+ API_ENDPOINT_URL = "https://zenquotes.io/api/random/"
21
+ return requests .get (API_ENDPOINT_URL ).json ()
22
+
23
+
24
+ if __name__ == "__main__" :
25
+ """
26
+ response object has all the info with the quote
27
+ To retrieve the actual quote access the response.json() object as below
28
+ response.json() is a list of json object
29
+ response.json()[0]['q'] = actual quote.
30
+ response.json()[0]['a'] = author name.
31
+ response.json()[0]['h'] = in html format.
32
+ """
33
+ response = random_quotes ()
34
+ pprint .pprint (response )
You can’t perform that action at this time.
0 commit comments