API Reference#
The API Reference for the library which includes all the Classes and methods.
Client#
The client which connects you with the API.
- class DuckDuck.Duck[source]#
The main client class.
- async fetch_gif(gif: int, /) _io.BytesIO[source]#
Fetches a specified gif from the API.
- Parameters
gif (
int) – The gif to fetch.- Return type
io.BytesIO
- async fetch_http(code: int, /) _io.BytesIO[source]#
Fetches a specified http from the API.
- Parameters
code (
int) – The http image to fetch- Return type
io.BytesIO
- async fetch_jpg(jpg: int, /) _io.BytesIO[source]#
Fetches a specified jpg from the API.
- Parameters
jpg (
int) – The jpg to fetch.- Return type
io.BytesIO
- async fetch_list(*, gif: bool = False, jpg: bool = False, http: bool = False) dict[str, list[str] | int] | list[str][source]#
A method to get a specific list from the API, if no list is specified then everything is returned.
- Parameters
gif (
Optional[bool]) – Whether to only get the gif list of the dict.jpg (
Optional[bool]) – Whether to only get the jpg list of the dict.http (
Optional[bool]) – Whether to only get the http list of the dict.
- Return type
dict[str, list[str] | int] | list[str]
- async fetch_random(*, gif: bool = False, jpg: bool = False) str[source]#
Fetches a random jpg link or a gif link from the API, if the type of link isn’t specified then the API will randomly return either a jpg or a gif url. Note that since there’s a lot more jpgs than gifs in the api, jpgs will get returned more frequently.
- Parameters
gif (
Optional[bool]) – Whether to fetch only gif from the API, default is set toFalse.jpg (
Optional[bool]) – Whether to fetch only jpg from the API, default is set toFalse.
- Return type
str
- async fetch_random_file(*, gif: bool = False, jpg: bool = False) _io.BytesIO[source]#
Fetches a random jpg file or a gif file from the API, if the type of file isn’t specified then the API will randomly return either a jpg or a gif file. Note that since there’s a lot more jpgs than gifs in the api, jpgs will get returned more frequently.
- Parameters
gif (
Optional[bool]) – Whether to fetch only gif from the API, default is set toFalse.jpg (
Optional[bool]) – Whether to fetch only jpg from the API, default is set toFalse.
- Return type
io.BytesIO
Cache#
Cache-ing your data.
- class DuckDuck._Cache[source]#
- property get_cache: dict[str, list[str | io.BytesIO | bytes]]#
Gets the entire cache.
- Return type
Dict[
str, List[Union[str,io.BytesIO,bytes]]]
- property gif_cache: list[str | io.BytesIO | bytes] | None#
Returns the gif list from the cache, if there isn’t any gif cached it returns none.
- Return type
Optional[List[Union[
str,io.BytesIO,bytes]]
- property http_cache: list[str | io.BytesIO | bytes] | None#
Returns the http list from the cache, if there isn’t any http cached yet it returns none.
- Return type
Optional[List[Union[
str,io.BytesIO,bytes]]
- property jpg_cache: list[str | io.BytesIO | bytes] | None#
Returns the jpg list from the cache, if there isn’t any jpg it returns none.
- Return type
Optional[List[Union[
str,io.BytesIO,bytes]]