Skip to main content

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 de all_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.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiocospend 0.6.0
File Size Uploaded Provenance Actions
aiocospend-0.6.0.tar.gz 39.8 kB With provenance Details for aiocospend-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiocospend 0.6.0
File Interpreter ABI Platform Actions
aiocospend-0.6.0-py3-none-any.whl Python 3 none any Details for aiocospend-0.6.0-py3-none-any.whl

Total release size: 68.2 kB

Release files / aiocospend-0.6.0.tar.gz

Download URL aiocospend-0.6.0.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5c4caf66b1f91359e7085dfebf410b099395a3c48300e45a8980c8a8a30a5ae3
BLAKE2b-256 checksum
How to use checksums
a03412fd2ff19ce581d88a8b750b18b69afc6a3e4a6d335e78790be955bb2961
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 20, 2026.

Transparency log

Release files / aiocospend-0.6.0-py3-none-any.whl

Download URL aiocospend-0.6.0-py3-none-any.whl
Size 28.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
809947bcbba5d908db7ea4d54ceae21421cee6e454d7c0dbd96ea535f4ab5b96
BLAKE2b-256 checksum
How to use checksums
b064efdaea5505537ed74dbc49803e13a61241335b1f8b50f4564e7752f6b1db
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 20, 2026.

Transparency log

Security for aiocospend 0.6.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.

Select from 2 files

Attestation for aiocospend-0.6.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 20, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page