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.3.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.3.0
File Size Uploaded Provenance Actions
aiocospend-0.3.0.tar.gz 35.6 kB With provenance Details for aiocospend-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 61.6 kB

Release files / aiocospend-0.3.0.tar.gz

Download URL aiocospend-0.3.0.tar.gz
Size 35.6 kB
Tags Source
SHA-256 checksum
How to use checksums
19730d89b042dadf7950bb2f7ebdf5dacd6f7a75c549227548c630df2b3c4cc7
BLAKE2b-256 checksum
How to use checksums
550fc2e669eebe4c5f94e050d6965d4350561124f7f324f8685751f9572c242c
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 log

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

Download URL aiocospend-0.3.0-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb3ad9af63dad2eab4d5758e066b81980b9be9fac7f45bad28d1c0f0d4945759
BLAKE2b-256 checksum
How to use checksums
3d32ba38a660d22e073ab8dd98c5c97ab4ad2d05abdc8a1f8b77727e167e43b3
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 log

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