@@ -42,15 +42,19 @@ Note that joke submissions are manually checked and you will be ratelimited.
4242### Example
4343
4444``` python
45- from jokeapi import Jokes # Import the Jokes class
46-
47- j = Jokes() # Initialise the class
48- joke = j.get_joke()[0 ] # Retrieve a random joke
49- if joke[" type" ] == " single" : # Print the joke
50- print (joke[" joke" ])
51- else :
52- print (joke[" setup" ])
53- print (joke[" delivery" ])
45+ from jokeapi import Jokes # Import the Jokes class
46+ import asyncio
47+
48+ async def print_joke ():
49+ j = await Jokes() # Initialise the class
50+ await j.get_joke() # Retrieve a random joke
51+ if joke[" type" ] == " single" : # Print the joke
52+ print (joke[" joke" ])
53+ else :
54+ print (joke[" setup" ])
55+ print (joke[" delivery" ])
56+
57+ asyncio.run(print_joke())
5458```
5559
5660### Parameters
@@ -71,7 +75,7 @@ If left blank it will default to use `Any`.
7175##### Example
7276
7377``` python
74- joke = j.get_joke(category = [' programming' , ' dark' ]) # Will return a joke that fits in either the programming or dark category.
78+ joke = await j.get_joke(category = [' programming' , ' dark' ]) # Will return a joke that fits in either the programming or dark category.
7579```
7680
7781---
@@ -91,7 +95,7 @@ If left blank it will default to `None`.
9195##### Example
9296
9397``` python
94- joke = j.get_joke(blacklist = [' nsfw' , ' racist' ]) # Will return a joke that does not have either the flag "nsfw" or "racist".
98+ joke = await j.get_joke(blacklist = [' nsfw' , ' racist' ]) # Will return a joke that does not have either the flag "nsfw" or "racist".
9599```
96100
97101---
@@ -110,7 +114,7 @@ If left blank it will default to `json`.
110114##### Example
111115
112116``` python
113- joke = j.get_joke(response_format = " xml" ) # Will return a joke in xml format.
117+ joke = await j.get_joke(response_format = " xml" ) # Will return a joke in xml format.
114118```
115119
116120---
@@ -128,7 +132,7 @@ If left blank it will default to `Any`
128132##### Example
129133
130134``` python
131- joke = j.get_joke(joke_type = " twopart" ) # Will return a twopart joke; both a setup and a delivery.
135+ joke = await j.get_joke(joke_type = " twopart" ) # Will return a twopart joke; both a setup and a delivery.
132136```
133137
134138---
@@ -142,7 +146,7 @@ If left blank it will default to `None`
142146##### Example
143147
144148``` python
145- joke = j.get_joke(search_string = " the" ) # Will return a joke with the word "the" in it.
149+ joke = await j.get_joke(search_string = " the" ) # Will return a joke with the word "the" in it.
146150 # If there are no jokes then it will return the error from the API.
147151```
148152
@@ -160,7 +164,7 @@ If left blank it will default to the maximum range.
160164##### Example
161165
162166``` python
163- joke = j.get_joke(id_range = [10 ,100 ]) # Will return a joke with the ID between 10 and 100.
167+ joke = await j.get_joke(id_range = [10 ,100 ]) # Will return a joke with the ID between 10 and 100.
164168```
165169
166170---
@@ -174,7 +178,7 @@ api defaults to 1 if you use a number larger than the maximum. Defaults to 1.
174178##### Example
175179
176180``` python
177- joke = j.get_joke(amount = 2 ) # Will return 2 jokes.
181+ joke = await j.get_joke(amount = 2 ) # Will return 2 jokes.
178182```
179183
180184---
@@ -187,7 +191,7 @@ documentation. Defaults to en.
187191##### Example
188192
189193``` python
190- joke = j.get_joke(lang = " de" )
194+ joke = await j.get_joke(lang = " de" )
191195```
192196
193197---
@@ -201,7 +205,7 @@ more requests than normal users. Defaults to None
201205##### Example
202206
203207``` python
204- joke = j.get_joke(auth_token = " aaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbb" ) # Will send the token to the api in a header.
208+ joke = await j.get_joke(auth_token = " aaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbb" ) # Will send the token to the api in a header.
205209```
206210
207211---
@@ -216,7 +220,7 @@ to change it
216220##### Example
217221
218222``` python
219- joke = j.get_joke(user_agent = " Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0" )
223+ joke = await j.get_joke(user_agent = " Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0" )
220224 # This is in fact the default user agent, and tells the API that we are visitng the page from a Firefox 77.0
221225 # browser using Windows 10 64bit.
222226```
@@ -233,7 +237,7 @@ Defaults to False.
233237##### Example
234238
235239``` python
236- response = j.get_joke(return_headers = True )
240+ response = await j.get_joke(return_headers = True )
237241 joke = response[0 ]
238242 headers = response[1 ]
239243
@@ -340,16 +344,20 @@ If not, feel free to ask me through one of the channels provided below.
340344
341345``` python
342346from jokeapi import Jokes
347+ import asyncio
343348
344- j = Jokes()
349+ async def submit_new_joke ():
350+ j = await Jokes()
345351
346- j.submit_joke(" Miscellaneous" , " funny haha" , {
347- " nsfw" : False ,
348- " religious" : False ,
349- " political" : False ,
350- " racist" : False ,
351- " sexist" : False
352- }, lang = " de" )
352+ await j.submit_joke(" Miscellaneous" , " funny haha" , {
353+ " nsfw" : False ,
354+ " religious" : False ,
355+ " political" : False ,
356+ " racist" : False ,
357+ " sexist" : False
358+ }, lang = " de" )
359+
360+ asyncio.run(submit_new_joke())
353361```
354362
355363---
@@ -417,8 +425,6 @@ Defaults to `en`
417425
418426![ Discord] ( https://discord.com/assets/07dca80a102d4149e9736d4b162cff6f.ico ) [ ** Discord** ] ( https://discord.gg/mB989eP )
419427
420- [ Issue Tracker] ( https://github.com/thenamesweretakenalready/Sv443s- JokeAPI-Python-Wrapper /issues )
428+ [ Issue Tracker] ( https://github.com/thenamesweretakenalready/JokeAPI-Python/issues )
421429
422430[ e-mail
] ( mailto:[email protected] ) 423-
424- [ Twitter] ( https://twitter.com/HakkerLeet )
0 commit comments