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.7.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.7.0
File Size Uploaded Provenance Actions
aiocospend-0.7.0.tar.gz 41.9 kB With provenance Details for aiocospend-0.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 71.9 kB

Release files / aiocospend-0.7.0.tar.gz

Download URL aiocospend-0.7.0.tar.gz
Size 41.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fab3da25df25606e37542817f43ce408467ccac703e460d217cab13f63f4f4c6
BLAKE2b-256 checksum
How to use checksums
323075760b74ffdf890bce3c7bfbafd1b078b363ccd7056bec1913a199c18822
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.7.0-py3-none-any.whl

Download URL aiocospend-0.7.0-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
759ea386608fa0cf8994f13b736f358fbe8eb6fbf279f8060fa5f1df8c0807ad
BLAKE2b-256 checksum
How to use checksums
85b72b91ae2bd3862493b92e2df559fab41edc1cea8fc130ab31da0cc46944cd
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.7.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.7.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