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.1

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.1
File Size Uploaded Provenance Actions
aiocospend-0.6.1.tar.gz 40.8 kB With provenance Details for aiocospend-0.6.1.tar.gz

Built distribution (wheel)

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

Total release size: 69.8 kB

Release files / aiocospend-0.6.1.tar.gz

Download URL aiocospend-0.6.1.tar.gz
Size 40.8 kB
Tags Source
SHA-256 checksum
How to use checksums
750c65b7e6a0471158673555e4c23e33dd1eaf8092209b80c9b29e96c285b770
BLAKE2b-256 checksum
How to use checksums
1e6faf5d10edc4bce8ec2ea5aa3fe1ef3ef5aa81815cdf43f61b76a0ed82d115
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.1-py3-none-any.whl

Download URL aiocospend-0.6.1-py3-none-any.whl
Size 29.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0ad9a6a05d826cc80d4e959e68e77236d3506609255dd91a297860527ca4218
BLAKE2b-256 checksum
How to use checksums
e0164418db85186df70cd99e5721c7cf2142e79a1fc726ed8366c0d2caae722b
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.1

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.1.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