Skip to content

Stats endpoint #5

@swantzter

Description

@swantzter

I'm thinking an endpoint at

GET /libera/stats which returns either of the following based on the accept header:

application/json: A json payload with: currently receiving per month, received YTD
text/html: The same thing but as a cute little ifram friendly widget we can put on libera.chat without client JS
or do we do the latter with image/svg+xml maybe?

Most likely the thing to do here is:

  1. Retrieve the current balance of account 3993 from spiris using /v2/accountbalances/{accountNumber}/{date} which will tell you how much has been donated YTD
  2. Retrieve all currently active subscriptions from stripe tagged with the appropriate libera donations tag, and sum their amount per momth in SEK, likely using the preview stripe FX Quotes API to get the conversion rates, this gives a figure for money / month
  3. Can we receive the current sum from Liberapay? I don't think we can in a good way, but for the html version we might be able to use one of the widgets, like liberapay-widget
  4. Cache these values in memory for 24 hours or something like that, also utilise HTTP cache headers to cache it upstream
  5. Add cors for the endpoint to allow getting the data via JS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions