Python SDK for interacting with the Turnkey API.
This is a monorepo containing multiple packages:
turnkey-sdk-types- Pydantic type definitions for Turnkey APIturnkey-http- HTTP client for making API requeststurnkey-api-key-stamper- API key authentication stamper
pip install turnkey-http turnkey-api-key-stamperfrom turnkey_http import TurnkeyClient
from turnkey_api_key_stamper import ApiKeyStamper, ApiKeyStamperConfig
# Initialize stamper
config = ApiKeyStamperConfig(
api_public_key="your-api-public-key",
api_private_key="your-api-private-key"
)
stamper = ApiKeyStamper(config)
# Create client
client = TurnkeyClient(
base_url="https://api.turnkey.com",
stamper=stamper,
organization_id="your-org-id"
)
# Make API calls
response = client.get_whoami()
print(response)- Python 3.8+
- pip
- Clone the repository:
git clone https://github.com/tkhq/python-sdk.git
cd python-sdk- Create and activate virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install all packages in editable mode:
make installThis installs all packages with their dev dependencies in editable mode, so changes take effect immediately.
This SDK uses code generation to stay in sync with the Turnkey API:
make generate # Generate both types and HTTP client
# or
make generate-types # Generate types only
make generate-http # Generate HTTP client onlymake testBefore committing, run these commands to ensure code cleanliness:
make format # Format code with ruff
make typecheck # Check types with mypy
make test # Run testspython-sdk/
├── packages/
│ ├── sdk-types/ # Type definitions
│ │ ├── src/
│ │ └── scripts/ # Code generator
│ ├── http/ # HTTP client
│ │ ├── src/
│ │ ├── scripts/ # Code generator
│ │ └── tests/
│ └── api-key-stamper/ # Authentication
│ └── src/
├── schema/ # OpenAPI spec
└── examples/ # Example usage