Skip to content

Instantly share code, notes, and snippets.

@lemajes
Last active February 3, 2026 19:14
Show Gist options
  • Select an option

  • Save lemajes/4d5e94684e269520201308b5bfc825c9 to your computer and use it in GitHub Desktop.

Select an option

Save lemajes/4d5e94684e269520201308b5bfc825c9 to your computer and use it in GitHub Desktop.
OVH facture parsing for finops
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import ovh
import json
import os
import sys
import argparse
ovh_api_endpoint = os.environ['ovh_api_endpoint']
ovh_api_application_key = os.environ['ovh_api_application_key']
ovh_api_application_secret = os.environ['ovh_api_application_secret']
ovh_api_consumer_key = os.environ['ovh_api_consumer_key']
client = ovh.Client(
endpoint=ovh_api_endpoint,
application_key=ovh_api_application_key,
application_secret=ovh_api_application_secret,
consumer_key=ovh_api_consumer_key,
)
def main(args):
params = {}
# params['category'] = {}
params['date.from'] = args.start_date
params['date.to'] = args.end_date
result = client.get("/me/bill", **params)
# print(json.dumps(result, indent=4))
for item in result:
print(item)
this_bill = client.get(f"/me/bill/{item}/details")
print(json.dumps(this_bill, indent=4))
for bill in this_bill:
print(f"We're gonna get {bill} details coming from {item}")
this_bill_details = client.get(f"/me/bill/{item}/details/{bill}")
print(json.dumps(this_bill_details, indent=4))
if __name__ == '__main__':
print("Start: python3 get_invoices.py --start_date 2026-01-01T00:00:00 --end_date 2026-01-31T23:59:59")
parser = argparse.ArgumentParser(description='Fucking OVH bill parser')
parser.add_argument('-s', '--start_date',
help='Start date for billing',
required=True)
parser.add_argument('-e', '--end_date',
help='End date for billing',
required=True)
args = parser.parse_args()
main(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment