Skip to content

Datata1/codesphere-python

Codesphere

Python SDK

PyPI Python License

The official Python client for the Codesphere API.


Installation

uv add codesphere

Configuration

Create a .env file in your project root:

Variable Description Default
CS_TOKEN API token (required)
CS_BASE_URL API base URL https://codesphere.com/api

Quick Start

import asyncio
from codesphere import CodesphereSDK

async def main():
    async with CodesphereSDK() as sdk:
        teams = await sdk.teams.list()
        for team in teams:
            print(f"{team.name} (ID: {team.id})")

asyncio.run(main())

Usage

Teams

teams = await sdk.teams.list()
team = await sdk.teams.get(team_id=123)
await team.delete()

Workspaces

workspaces = await sdk.workspaces.list(team_id=123)
workspace = await sdk.workspaces.get(workspace_id=456)

result = await workspace.execute_command("ls -la")
print(result.output)

await workspace.env_vars.set([{"name": "API_KEY", "value": "secret"}])
env_vars = await workspace.env_vars.get()

Domains

team = await sdk.teams.get(team_id=123)
domains = await team.domains.list()
domain = await team.domains.create(name="api.example.com")

Metadata

datacenters = await sdk.metadata.list_datacenters()
plans = await sdk.metadata.list_plans()
images = await sdk.metadata.list_images()

Development

git clone https://github.com/Datata1/codesphere-python.git
cd codesphere-python
uv sync --all-extras
uv run pytest

License

MIT – see LICENSE for details.

About

A Codesphere Public API wrapper

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published