BlaguesAPI Python
Ce paquet Python fournit une interface simple pour intéragir avec Blagues API.
Important : Ce paquet ne fournit que des méthodes asynchrones.
Installation
Vous pouvez simplement ajouter la dépendance à votre projet depuis PyPI :
pip install blagues-api
Utilisation
Pour utiliser l'API, vous devez obtenir une clé gratuite sur le site officiel : https://www.blagues-api.fr/. Vous pourrez ensuite construire un objet BlaguesAPI :
from blagues_api import BlaguesAPI
blagues = BlaguesAPI("VOTRE_TOKEN_ICI")
Toutes les méthodes excepté count renverront un objet Blague, qui permet d'accéder aux différentes propriétés renvoyées par l'API : id, type, joke, answer. En cas d'erreur, vous recevrez une erreur du type aiohttp.ClientResponseError.
Les différents types de blagues peuvent être représentés au choix sous forme d'un string ou d'un objet BlagueType (exemple: BlagueType.GENERAL). La liste des types disponibles est notée dans sur le site officiel.
Blague aléatoire
await blagues.random()
# Blague(id=108, type=<BlagueType.GLOBAL: 'global'>, joke="C'est l'histoire d'un poil. Avant, il était bien.", answer='Maintenant, il est pubien.')
Il est possible de spécifier des catégories à exclure :
await blagues.random(disallow=[BlagueType.LIMIT, BlagueType.BEAUF])
# Avec des strings
await blagues.random(disallow=["limit", "beauf"])
Blague aléatoire catégorisée
await blagues.random_categorized(BlagueType.DEV)
# Blague(id=430, type=<BlagueType.DEV: 'dev'>, joke='De quelle couleur sont tes yeux ?', answer='#1292f4 et toi ?')
# Avec des strings
await blagues.random_categorized("dev")
Blague par identifiant
await blagues.from_id(20)
# Blague(id=20, type=<BlagueType.GLOBAL: 'global'>, joke="Qu'est-ce qu'un chou au milieu de l'océan ?", answer='Un chou marin.')
Nombre de blagues
await blagues.count()
# CountJoke(count=1730)
La méthode ci-dessus renverra un objet CountJoke, qui permet d'accéder a la propriété renvoyée par l'API : count. En cas d'erreur, vous recevrez une erreur du type aiohttp.ClientResponseError.
Metadata
Release files for blagues-api 1.0.4
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 |
|---|---|---|---|---|
| blagues_api-1.0.4.tar.gz | 3.6 kB | Without provenance | Details for blagues_api-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blagues_api-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for blagues_api-1.0.4-py3-none-any.whl |
Total release size: 7.7 kB
Release files / blagues_api-1.0.4.tar.gz
| Download URL | blagues_api-1.0.4.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22c18266956d5526bad242bf91ce6d9f724427041d2a584b29ded926567b7254
|
|
BLAKE2b-256 checksum How to use checksums |
0fff3bd3347911fc02478e8c28aa1aa9d7c03292f01c1df4d221b1d5dd8e9c40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / blagues_api-1.0.4-py3-none-any.whl
| Download URL | blagues_api-1.0.4-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78c44749495187d7645a91147241ac2400a0b785a4f3443987efae8096b1f097
|
|
BLAKE2b-256 checksum How to use checksums |
0b79a8407239b53c20cfc622e87c52cb137ac09281d13d9e4359b9e6e2c349c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Security for blagues-api 1.0.4
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.