Turnkey HTTP
HTTP client for the Turnkey API with auto-generated methods from the OpenAPI specification.
Installation
pip install turnkey-http
Or install from the repository in editable mode:
pip install -e packages/http
Usage
from turnkey_http import TurnkeyClient
from turnkey_api_key_stamper import ApiKeyStamper, ApiKeyStamperConfig
# Initialize the stamper
config = ApiKeyStamperConfig(
api_public_key="your-api-public-key",
api_private_key="your-api-private-key"
)
stamper = ApiKeyStamper(config)
# Create the HTTP client
client = TurnkeyClient(
base_url="https://api.turnkey.com",
stamper=stamper,
organization_id="your-org-id"
)
# Make API calls with typed methods
response = client.get_whoami()
print(response)
Handling activity outcomes
Activity methods poll until the activity finishes. If it does not complete, they raise an error. TurnkeyActivityConsensusNeededError means the activity needs more approvals. TurnkeyActivityAuthenticatorsNeededError means it needs authenticator approval. TurnkeyActivityError means it failed, was rejected, or was still pending when polling stopped. These errors carry activity_id, activity_status, activity_type, and failure. Catch the subclasses first, because they extend TurnkeyActivityError.
Consensus-needed and authenticators-needed each stop the normal activity poll. Pass a PollingConfig as consensus_polling or mfa_polling to keep polling that status. The MFA interval doubles on each attempt, up to 5 seconds. The consensus interval stays fixed. Omit a config to raise that status's error immediately. A timeout raises the same error. Use activity_id with get_activity after the missing approvals are in place.
from turnkey_http import PollingConfig, TurnkeyClient
from turnkey_sdk_types import (
TurnkeyActivityAuthenticatorsNeededError,
TurnkeyActivityConsensusNeededError,
TurnkeyActivityError,
)
client = TurnkeyClient(
base_url="https://api.turnkey.com",
stamper=stamper,
organization_id="your-org-id",
consensus_polling=PollingConfig(interval_ms=500, timeout_ms=30_000),
mfa_polling=PollingConfig(interval_ms=500, timeout_ms=30_000),
)
try:
response = ... # any activity method
except TurnkeyActivityConsensusNeededError as err:
activity_id = err.activity_id
except TurnkeyActivityAuthenticatorsNeededError as err:
activity_id = err.activity_id
except TurnkeyActivityError as err:
print(err.activity_status, err.failure)
Code Generation
This package uses code generation to create HTTP client methods from the OpenAPI specification located in schema/public_api.swagger.json.
Generate Client
To regenerate the HTTP client:
cd packages/http
python3 scripts/generate.py
The generator automatically formats code with ruff.
Development Setup
Install with dev dependencies:
pip install -e ".[dev]"
Structure
http/
├── src/
│ └── turnkey_http/
│ ├── __init__.py
│ └── generated/ # Auto-generated client (do not edit manually)
├── scripts/
│ └── generate.py # Code generation script
├── tests/ # Test suite
├── pyproject.toml
└── README.md
Dependencies
- Python >= 3.8
- requests >= 2.31.0
- turnkey-api-key-stamper
- turnkey-sdk-types
Development
The generated client is created from the OpenAPI specification with:
- Typed methods for each API endpoint
- Automatic request signing via stamper integration
- Type hints using types from
turnkey-sdk-types
Important: Never edit files in src/turnkey_http/generated/ manually. They will be overwritten on the next generation run.
Metadata
Release files for turnkey-http 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| turnkey_http-0.2.0.tar.gz | 30.4 kB | With provenance | Details for turnkey_http-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| turnkey_http-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for turnkey_http-0.2.0-py3-none-any.whl |
Total release size: 54.2 kB
Release files / turnkey_http-0.2.0.tar.gz
| Download URL | turnkey_http-0.2.0.tar.gz |
|---|---|
| Size | 30.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
021acd3062627a336c23cce039d8a31170f26d19274f3278e5d3012b52d4289e
|
|
BLAKE2b-256 checksum How to use checksums |
d5b048204ae422e46c017fdfb236239ab41c16600cf8af7412842329bd73fe47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logRelease files / turnkey_http-0.2.0-py3-none-any.whl
| Download URL | turnkey_http-0.2.0-py3-none-any.whl |
|---|---|
| Size | 23.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7218878105cb1e5fe541b9a225945556a903ab5d016771f69379b00d4185b055
|
|
BLAKE2b-256 checksum How to use checksums |
b30027dca7765fd5f4ab056fcd2d736a3b41b50adb7ffa1c48bc858817a2509c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logSecurity for turnkey-http 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for turnkey_http-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.