A Python client library for accessing the Rootly API v1. This SDK provides both synchronous and asynchronous interfaces for interacting with Rootly's incident management platform.
pip install rootlyFirst, create a client:
from rootly_sdk import Client
client = Client(base_url="https://api.rootly.com")For endpoints that require authentication, use AuthenticatedClient:
from rootly_sdk import AuthenticatedClient
client = AuthenticatedClient(
base_url="https://api.rootly.com",
token="your-api-token"
)from rootly_sdk.models import MyDataModel
from rootly_sdk.api.my_tag import get_my_data_model
from rootly_sdk.types import Response
# Simple synchronous call
with client as client:
my_data: MyDataModel = get_my_data_model.sync(client=client)
# Or get detailed response (includes status_code, headers, etc.)
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)from rootly_sdk.models import MyDataModel
from rootly_sdk.api.my_tag import get_my_data_model
from rootly_sdk.types import Response
async with client as client:
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)By default, the client verifies SSL certificates. For internal APIs with custom certificates:
client = AuthenticatedClient(
base_url="https://internal-api.example.com",
token="your-api-token",
verify_ssl="/path/to/certificate_bundle.pem",
)Warning: Disabling SSL verification is a security risk and should only be used in development:
client = AuthenticatedClient(
base_url="https://internal-api.example.com",
token="your-api-token",
verify_ssl=False
)You can customize the underlying httpx.Client with event hooks and other options:
from rootly_sdk import Client
def log_request(request):
print(f"Request: {request.method} {request.url}")
def log_response(response):
print(f"Response: {response.request.method} {response.request.url} - Status {response.status_code}")
client = Client(
base_url="https://api.rootly.com",
httpx_args={
"event_hooks": {
"request": [log_request],
"response": [log_response]
}
},
)Access the underlying httpx client directly:
# Synchronous client
httpx_client = client.get_httpx_client()
# Asynchronous client
async_httpx_client = client.get_async_httpx_client()Set a custom httpx client (note: this overrides base_url and other settings):
import httpx
from rootly_sdk import Client
client = Client(base_url="https://api.rootly.com")
client.set_httpx_client(
httpx.Client(
base_url="https://api.rootly.com",
proxies="http://localhost:8030"
)
)The SDK is structured as follows:
-
Four function variants per endpoint:
sync: Blocking request returning parsed data orNonesync_detailed: Blocking request returning fullResponseobjectasyncio: Async version ofsyncasyncio_detailed: Async version ofsync_detailed
-
Module organization:
- Path/query parameters and request bodies become function arguments
- Endpoints are grouped by their first OpenAPI tag (e.g.,
rootly_sdk.api.incidents) - Untagged endpoints are in
rootly_sdk.api.default
- Python 3.9 or higher
- uv (recommended) or pip
# Clone the repository
git clone https://github.com/rootlyhq/rootly-python.git
cd rootly-python
# Install in editable mode
pip install -e .To regenerate the client from the latest OpenAPI specification:
openapi-python-client generate \
--url https://rootly-heroku.s3.amazonaws.com/swagger/v1/swagger.json \
--no-fail-on-warning \
--output-path . \
--overwrite \
--config tools/config.yaml# Install build tools
pip install uv
uv pip install build
# Build distribution files
python -m build# Verify SDK imports successfully
python -c "import rootly_sdk; print('SDK imports successfully')"- Update the version in
pyproject.toml - Update
CHANGELOG.mdwith release notes - Create and push a git tag:
git tag v1.0.0 git push origin v1.0.0
- GitHub Actions will automatically build and publish to PyPI
See .github/PUBLISHING.md for detailed publishing instructions.
If you need to publish manually:
# Install dependencies
pip install uv
uv pip install build twine
# Build the package
python -m build
# Publish to PyPI
twine upload dist/*- httpx >= 0.20.0, < 0.29.0 - HTTP client
- attrs >= 22.2.0 - Data classes
- python-dateutil >= 2.8.0 - Date parsing
Apache 2.0
For issues, questions, or contributions, please visit the GitHub repository.