Skip to main content

Official Python SDK for BambooSnow AI agent automation platform

Project description

BambooSnow Python SDK

Official Python SDK for the BambooSnow AI agent automation platform.

Installation

pip install bamboosnow

Quick Start

from bamboosnow import BambooSnowClient

# Using environment variable BAMBOOSNOW_API_KEY
client = BambooSnowClient()

# Or pass the API key directly
client = BambooSnowClient(api_key="bs_...")

# List your agents
agents = client.agents.list()
for agent in agents.items:
    print(f"{agent.name}: {agent.status}")

# Get a specific run
run = client.runs.get("run_abc123")
print(f"Status: {run.status}, Tokens: {run.tokens_used}")

# Approve a pending action
client.runs.approve("run_abc123", approved=True, comment="Looks good!")

Async Support

The SDK includes full async support:

import asyncio
from bamboosnow import AsyncBambooSnowClient

async def main():
    async with AsyncBambooSnowClient() as client:
        agents = await client.agents.list()
        for agent in agents.items:
            print(f"{agent.name}: {agent.status}")

asyncio.run(main())

Resources

Agents

# List agents
agents = client.agents.list(status="deployed")

# Get agent details
agent = client.agents.get("agt_abc123")

# Pause/resume agents
client.agents.pause("agt_abc123")
client.agents.resume("agt_abc123")

# Get agent health
health = client.agents.get_health("agt_abc123")
print(f"Grade: {health.grade}, Score: {health.overall_score}")

# Trigger a manual run
result = client.agents.trigger("agt_abc123", {"pr_number": 42})
print(f"Run ID: {result['run_id']}")

# List templates
templates = client.agents.list_templates()

Runs

# List runs
runs = client.runs.list(agent_id="agt_abc123")

# Get run details with thought trace
run = client.runs.get("run_abc123")
for step in run.thought_trace:
    print(f"[{step.type}] {step.content}")

# Approve/reject pending actions
client.runs.approve("run_abc123", approved=True)
client.runs.approve("run_abc123", approved=False, comment="Too risky")

# Cancel a running job
client.runs.cancel("run_abc123", reason="No longer needed")

# Wait for completion
run = client.runs.wait_for_completion(
    "run_abc123",
    on_progress=lambda r: print(f"Status: {r.status}")
)

# Get runs pending approval
pending = client.runs.get_pending_approvals()

Repositories

# List connected repos
repos = client.repositories.list()

# Connect a repository
repo = client.repositories.connect(
    provider="github",
    full_name="myorg/myrepo"
)

# Run analysis
analysis = client.repositories.analyze(repo.id)

# Wait for analysis to complete
analysis = client.repositories.wait_for_analysis(
    analysis.id,
    on_progress=lambda a: print(f"{a.progress_percent}% complete")
)

# Get latest analysis
latest = client.repositories.get_latest_analysis(repo.id)

API Keys

# List keys
keys = client.api_keys.list()

# Create a new key
result = client.api_keys.create(name="CI/CD Key")
print(f"Key: {result['key']}")  # Only shown once!

# Revoke a key
client.api_keys.revoke("key_abc123")

Configuration

Environment Variables

  • BAMBOOSNOW_API_KEY: Your API key
  • BAMBOOSNOW_BASE_URL: Custom API base URL (for self-hosted)

Client Options

client = BambooSnowClient(
    api_key="bs_...",
    base_url="https://api.bamboosnow.co",  # or self-hosted URL
    timeout=60.0,  # request timeout in seconds
    max_retries=3,  # retry attempts for failed requests
)

Error Handling

from bamboosnow import BambooSnowClient
from bamboosnow.errors import (
    APIError,
    AuthenticationError,
    NotFoundError,
    RateLimitError,
    ValidationError,
)

client = BambooSnowClient()

try:
    agent = client.agents.get("agt_abc123")
except AuthenticationError:
    print("Invalid API key")
except NotFoundError:
    print("Agent not found")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after} seconds")
except ValidationError as e:
    print(f"Validation error: {e.errors}")
except APIError as e:
    print(f"API error: {e.message}")

Type Hints

The SDK is fully typed. All models are Pydantic v2 models with full IDE support:

from bamboosnow import Agent, AgentStatus

def process_agent(agent: Agent) -> None:
    if agent.status == AgentStatus.DEPLOYED:
        print(f"{agent.name} is running")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bamboosnow-0.1.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bamboosnow-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file bamboosnow-0.1.0.tar.gz.

File metadata

  • Download URL: bamboosnow-0.1.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bamboosnow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 87157e9a6dbba7d3fd02869f4f845c5a92196c8434591ccbd939b485adef5409
MD5 7c85e5ab55e22b59dcb9d6ce47c6a5b1
BLAKE2b-256 154a2f35813117b89aa6219e5a9ae60fc06efcb6df16b959847b7cfdd430e577

See more details on using hashes here.

Provenance

The following attestation bundles were made for bamboosnow-0.1.0.tar.gz:

Publisher: publish-pypi.yml on HCS412/BambooSnow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bamboosnow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bamboosnow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bamboosnow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cee1b44b722239b9b8df99e44e0dce13abd9dbeae0ed8930e98c397da3d0cb9
MD5 091150eeb1d5e889a66e94e45f18898d
BLAKE2b-256 35333bcc1ba310a87544d9cc17f5c40fdc21be9eb2f062b9f2949750b22732cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for bamboosnow-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on HCS412/BambooSnow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page