Skip to content

feat(sdk): added python support for monthly billing report - #70

Open
bmaydan wants to merge 12 commits into
mainfrom
ben/monthly-billing-report
Open

feat(sdk): added python support for monthly billing report#70
bmaydan wants to merge 12 commits into
mainfrom
ben/monthly-billing-report

Conversation

@bmaydan

@bmaydan bmaydan commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

What

Adds Organization.get_monthly_summary() for fetching an organization's monthly billing summary (credits purchased, used, and remaining) from the billing service.

Details

  • OrgApi.get_monthly_summary() wraps billing_service_get_monthly_summary, exposing a single start/end interface that implicitly maps onto the API's two mutually exclusive filter modes:
    • both start and end: translated to a range filter.
    • only start: translated to a pivot filter with pivot=start, pivot_direction="AFTER".
    • only end: translated to a pivot filter with pivot=end, pivot_direction="BEFORE".
  • Validates that at least one of start/end is provided, that start <= end when both are given, and that the requested span doesn't exceed the API's 2-year limit (also enforced for the implicit AFTER pivot relative to now).
  • Organization.get_monthly_summary() exposes the same start/end interface at the SDK's public surface, scoped to self.id.

Example output

from lightning_sdk import Organization

org = Organization("my-org")
summary = org.get_monthly_summary(pivot=..., pivot_direction="BEFORE")
print(summary) ->
[
    {
      "periodStart": "2025-01-01T00:00:00Z",
      "periodEnd": "2025-02-01T00:00:00Z",
      "totalCreditsConsumed": (...),
      "totalCreditsRemaining": (...),
      "totalCreditsPurchased": (...)
    },
    {
      "periodStart": "2025-02-01T00:00:00Z",
      "periodEnd": "2025-03-01T00:00:00Z",
      "totalCreditsConsumed": (...),
      "totalCreditsRemaining": (...),
      "totalCreditsPurchased": (...)
    },
    ...
],

Testing

  • Added unit tests in python/tests/api/test_org_api.py covering valid range/pivot usage and invalid-input cases (missing/both filters, inverted range, future AFTER pivot, >2 year spans).

@bmaydan
bmaydan enabled auto-merge (squash) July 31, 2026 22:22
@justusschock

justusschock commented Aug 4, 2026

Copy link
Copy Markdown
Member

@bmaydan needs a pr description (ideally with an example output) :)

Comment thread python/lightning_sdk/organization.py Outdated
Comment thread python/lightning_sdk/organization.py Outdated
@bmaydan

bmaydan commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

@bmaydan needs a pr description (ideally with an example output) :)

added!

@bmaydan
bmaydan requested a review from justusschock August 5, 2026 01:52
Comment thread python/lightning_sdk/organization.py Outdated
@bmaydan
bmaydan requested review from dhedey and owbone as code owners August 6, 2026 01:03
@ethanwharris
ethanwharris disabled auto-merge August 7, 2026 08:06
@ethanwharris
ethanwharris requested a review from rusenask as a code owner August 7, 2026 08:16
Comment thread python/lightning_sdk/organization.py
Comment thread python/docs/sdk/conf.py Outdated
Comment thread python/lightning_sdk/api/org_api.py Outdated
@bmaydan
bmaydan requested a review from justusschock August 11, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants