PyGelbooru
PyGelbooru is an unofficial and lightweight asynchronous library for the Gelbooru API.
Installation
This library requires Python 3.6 or above.
You can install the library through pip as follows,
pip install pygelbooru
Usage
Searching
The primary use for this library is, naturally, to search for images with specific tags.
This can be done as so:
from pygelbooru import Gelbooru
# API key/user ID is optional, but access may be limited without them
gelbooru = Gelbooru('API_KEY', 'USER_ID')
results = await gelbooru.search_posts(tags=['dog ears', '1girl'], exclude_tags=['nude'])
[<GelbooruImage(id=5105386, filename='b77e69be0a4b...dde071dc.jpeg', owner='anon2003')>,
<GelbooruImage(id=5105161, filename='bf169f891ebe...02bceb5e.jpeg', owner='cpee')>,
<GelbooruImage(id=5104148, filename='46df3ebe2d41...4316d218e.jpg', owner='danbooru')>,
<GelbooruImage(id=5104080, filename='e8eec23d151e...419293401.png', owner='anon2003')>,
<GelbooruImage(id=5103937, filename='5bf279f3c546...be3fc53c8.jpg', owner='danbooru')>,
...
Tags can contain spaces when passed as arguments, they will simply be reformated with underscores before being queried, so you don't need to reformat them yourself.
Results are returned as a list of GelbooruImage containers. When cast to a string, this will return the image_url,
str(results[0])
'https://img2.gelbooru.com/images/b7/7e/b77e69be0a4b581eac597527dde071dc.jpeg'
You can also pull other information returned by the API, https://github.com/FujiMakoto/pygelbooru/blob/master/pygelbooru/gelbooru.py#L32-L47
Searching (Random)
In addition to searching for a large list of images, PyGelbooru also provides a helper method for when you're really just after a single, random image that matches the specified tags.
This method will automatically pull a random image from the last 20,000 Gelbooru image submissions.
result = await gelbooru.random_post(tags=['cat ears', '1girl', 'cat hood', 'bell'], exclude_tags=['nude'])
<GelbooruImage(id=5106718, filename='bbbdfbf9e883...161753514.png', owner='6498')>
Comments
You can fetch post comments directly from the GelbooruImage container,
post = await gelbooru.get_post(5099841)
await post.get_comments()
[<GelbooruComment(id=2486074, author='Anonymous', created_at='2020-01-28 08:47')>]
Tags
Besides searching for images, you can also pull information on tags as follows,
await gelbooru.tag_list(name='dog ears')
<GelbooruTag(id=773, name='dog_ears', count=22578)>
# Use "name_pattern" to search for partial matches to a specified tag
await gelbooru.tag_list(name_pattern='%splatoon%', limit=4)
[<GelbooruTag(id=892683, name='splatoon_(series)', count=11353)>,
<GelbooruTag(id=759189, name='splatoon_2', count=3488)>,
<GelbooruTag(id=612372, name='aori_(splatoon)', count=2266)>,
<GelbooruTag(id=612374, name='hotaru_(splatoon)', count=2248)>]
Metadata
Release files for pygelbooru 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pygelbooru-1.0.0.tar.gz | 19.9 kB | Without provenance | Details for pygelbooru-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pygelbooru-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pygelbooru-1.0.0-py3-none-any.whl |
Total release size: 39.5 kB
Release files / pygelbooru-1.0.0.tar.gz
| Download URL | pygelbooru-1.0.0.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
832fa7329a03bab1e45fa8c891a58084bda701e70ac4d48eae5260eaee4b3655
|
|
BLAKE2b-256 checksum How to use checksums |
b0ea27b0776b380022c3f3ecf0fbcce020709d686f2dd79e0921190bc9817b3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Release files / pygelbooru-1.0.0-py3-none-any.whl
| Download URL | pygelbooru-1.0.0-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bda4076da5cdd79e16aa2513165796bcbc8e35f03ab1423a08f5052b1bb59c95
|
|
BLAKE2b-256 checksum How to use checksums |
d680454665c21a121f83b36f9effa89924b9e563744c8ff47875668f2b8519a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Security for pygelbooru 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.