Skip to content

Repository files navigation

vantage-python

A Python SDK for the Vantage API. Types and client methods are auto-generated from the official OpenAPI specification.

Installation

pip install vantage-python

Usage

Synchronous Client

fromvantageimportClientclient=Client("your-api-token")
# List resources with query parametersreports=client.cost_reports.list(page=1)
# Get a specific resource by tokenreport=client.cost_reports.get("rprt_abc123")
# Create a new resourcefolder=client.folders.create(CreateFolder(
title="Production Costs",
workspace_token="wrkspc_123",
))
# Update a resourceclient.folders.update("fldr_abc123", UpdateFolder(
title="Updated Title",
))
# Delete a resourceclient.folders.delete("fldr_abc123")

Async Client

fromvantageimportAsyncClientasyncwithAsyncClient("your-api-token") asclient:
folders=awaitclient.folders.list()
folder=awaitclient.folders.create(CreateFolder(
title="Production Costs",
workspace_token="wrkspc_123",
))

Error Handling

API errors are raised as VantageAPIError with structured error information:

fromvantageimportClient, VantageAPIErrortry:
client.cost_reports.get("invalid_token")
exceptVantageAPIErrorase:
print(e.status) # 404print(e.status_text) # "Not Found"print(e.errors) # ["Resource not found"] or None

Development

Building

make install

This generates Pydantic models, sync client, and the async client. Your pip version will need to be up to date for this. If you wish to generate the client first, you should use make generate.

Testing

pytest

Publishing

make publish

About

Python SDK for the Vantage API

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages