xkcd-wrapper
A Python wrapper for the xkcd webcomic API.
Retrieves xkcd comic data and metadata as python objects.
Asynchronous (async) and synchronous implementations.
Installation
At the command line, with pip,
synchronous implementation:
$ pip install xkcd-wrapper[sync]
async implementation:
$ pip install xkcd-wrapper[async]
Usage
synchronous:
>>> import xkcd_wrapper
>>> client = xkcd_wrapper.Client()
>>> specific_comic = client.get(100) # Comic object with comic 100 data
>>> latest_comic = client.get_latest() # Comic object containing data of the latest xkcd comic
>>> random_comic = client.get_random() # Comic object of a random comic
>>> specific_comic
xkcd_wrapper.Comic(100)
>>> specific_comic.image_url
'https://imgs.xkcd.com/comics/family_circus.jpg'
async:
>>> import xkcd_wrapper, asyncio
>>> async_client = xkcd_wrapper.AsyncClient()
>>> async def async_call():
... responses = await asyncio.gather(
... async_client.get(100), # Comic object with comic 100 data
... async_client.get_latest(), # Comic object containing data of the latest xkcd comic
... async_client.get_random() # Comic object of a random comic
... )
... print(
... responses[0], # async_client.get(100) output
... responses[0].image_url,
... sep='\n'
... )
>>> asyncio.run(async_call())
xkcd_wrapper.Comic(100)
'https://imgs.xkcd.com/comics/family_circus.jpg'
Documentation
Check the documentation for more details: https://xkcd-wrapper.readthedocs.io/en/latest
History
1.0.2 (01-11-2022)
- Support Python 3.10
- Update dependencies
1.0.1 (28-02-2021)
- Deprecate Python 3.5
- Support Python 3.9
- Update dependencies
1.0.0 (06-09-2020)
- Reworked xkcd API response json decoding
- Reworked
Comic ClientandAsyncClientcan now retrieve comic images
0.2.2 (13-08-2020)
- Fixed failing to import
xkcd_wrapperif either onlyrequestsoraiohttpwere installed
0.2.1 (11-08-2020)
- Separate dependencies (you can now use the async implementation without having to install the sync dependencies and vice versa)
0.2.0 (08-08-2020)
- Async implementation (
AsyncClient)
0.1.0 (23-04-2020)
- First release on PyPI
ClientandComicclasses
Metadata
Release files for xkcd-wrapper 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xkcd-wrapper-1.0.2.tar.gz | 20.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xkcd_wrapper-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.2 kB
Release files / xkcd-wrapper-1.0.2.tar.gz
| Download URL | xkcd-wrapper-1.0.2.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bff9a0f2af940ad9833b5a179e97e1e66b3893c64deed1f30d4f2b1332184685
|
|
BLAKE2b-256 checksum How to use checksums |
89a28e64e513969ca91d84a356357e269c53772ad90f942217073444e2abc0aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Release files / xkcd_wrapper-1.0.2-py3-none-any.whl
| Download URL | xkcd_wrapper-1.0.2-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2b6f173abacd2ad3c7e98865779825c433718ac57f383345bf7a2262ff3fcb9
|
|
BLAKE2b-256 checksum How to use checksums |
d402089286ed5977c7a614c15b8ba7bab30b76c52855a59d8922c7c0318374ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|