Skip to content

vantage-sh/vantage-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

from vantage import Client

client = Client("your-api-token")

# List resources with query parameters
reports = client.cost_reports.list(page=1)

# Get a specific resource by token
report = client.cost_reports.get("rprt_abc123")

# Create a new resource
folder = client.folders.create(CreateFolder(
    title="Production Costs",
    workspace_token="wrkspc_123",
))

# Update a resource
client.folders.update("fldr_abc123", UpdateFolder(
    title="Updated Title",
))

# Delete a resource
client.folders.delete("fldr_abc123")

Async Client

from vantage import AsyncClient

async with AsyncClient("your-api-token") as client:
    folders = await client.folders.list()

    folder = await client.folders.create(CreateFolder(
        title="Production Costs",
        workspace_token="wrkspc_123",
    ))

Error Handling

API errors are raised as VantageAPIError with structured error information:

from vantage import Client, VantageAPIError

try:
    client.cost_reports.get("invalid_token")
except VantageAPIError as e:
    print(e.status)      # 404
    print(e.status_text)  # "Not Found"
    print(e.errors)       # ["Resource not found"] or None

Development

Building

make install

This fetches the latest OpenAPI schema from the Vantage API and generates Pydantic models, sync client, and async client. Your pip version will need to be up to date for this.

Testing

pytest

Publishing

make publish

About

Python SDK for the Vantage API

Resources

License

Stars

Watchers

Forks

Packages

No packages published