aiocospend
Client asynchrone (aiohttp) pour l'API OCS de Nextcloud Cospend. Fait partie du dépôt cospend-ha. Version 0.2.0.
import time
import aiohttp
from aiocospend import CospendClient
async with aiohttp.ClientSession() as session:
client = CospendClient(
session, "https://cloud.exemple.org", "utilisateur", "mot-de-passe-d-application"
)
await client.check_connection() # adresse, identifiants, version de Cospend (>= 1.6.1)
project = (await client.get_projects())[0] # membres, catégories, soldes inclus
page = await client.get_bills(project.id) # page.timestamp = curseur du prochain last_changed
delta = await client.get_bills(project.id, last_changed=page.timestamp)
bill_id = await client.create_bill(
project.id,
what="Courses",
amount=42.5,
payer_id=project.members[0].id,
payed_for=[m.id for m in project.members],
timestamp=int(time.time()),
date=time.strftime("%Y-%m-%d"),
)
await client.update_bill(project.id, bill_id, amount=45) # modification partielle
await client.delete_bill(project.id, bill_id) # corbeille
Synchronisation incrémentale
from aiocospend import ProjectBills
store = ProjectBills(project.id)
changes = await store.sync(
client, full_sync_max_age=24 * 3600
) # complète au besoin, sinon incrémentale
for bill in changes.added:
... # changes.updated, changes.deleted ; changes.is_initial = première lecture
À savoir (relevé sur Cospend 4.3.0)
- Les écritures sont envoyées en formulaire, avec tous les champs à la création (comme Cowspent).
- Supprimer une dépense déjà en corbeille la supprime définitivement. Le client ne rejoue jamais une suppression : relisez l'état de la dépense avant de réessayer.
- La lecture incrémentale (
last_changed) ne renvoie pas les dépenses mises en corbeille ; on les repère par leur absence deall_bill_ids. - Les montants renvoyés par le serveur (statistiques, remboursements) ne sont pas arrondis.
Tests
pip install -e ".[test]"
pytest tests # faux serveur Cospend local, sans réseau externe
Publication sur PyPI (mainteneur)
Le paquet est publié par le workflow manuel publish-aiocospend.yml, sans mot de passe, par
« Trusted Publisher » : sur pypi.org, ajouter un pending publisher (propriétaire SpaRtzZii,
dépôt cospend-ha, workflow publish-aiocospend.yml, environnement pypi), créer l'environnement
pypi dans les réglages du dépôt GitHub, puis lancer le workflow depuis l'onglet Actions.
Metadata
Release files for aiocospend 0.4.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 |
|---|---|---|---|---|
| aiocospend-0.4.0.tar.gz | 37.7 kB | With provenance | Details for aiocospend-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiocospend-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for aiocospend-0.4.0-py3-none-any.whl |
Total release size: 65.1 kB
Release files / aiocospend-0.4.0.tar.gz
| Download URL | aiocospend-0.4.0.tar.gz |
|---|---|
| Size | 37.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87bc656ecfd508840c988fb6b3a7ce9be284c919fdd6d9d3e7ef55f46924dba7
|
|
BLAKE2b-256 checksum How to use checksums |
67d619b8a239c37cce162c90ae5564935a530afeeff430785c3b17bb8c9f5e7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / aiocospend-0.4.0-py3-none-any.whl
| Download URL | aiocospend-0.4.0-py3-none-any.whl |
|---|---|
| Size | 27.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f02f5608dd09709b3a207fa996fea0b6e7806b2777bae1fbb42fccfc6980e916
|
|
BLAKE2b-256 checksum How to use checksums |
c3577cb95b0cc0cb7afd17c6fbc1a8677cef17d6c826970240f2d9a870c0d53d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for aiocospend 0.4.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for aiocospend-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA 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.