SRG+ Python SDK
Python client for the SRG+ API — manage hub profiles, channels, contents, assets, workspaces, and permissions.
Installation
pip install srgplus
Requires Python 3.11+ and depends on httpx and pydantic.
Quick start
from srg import SRGClient
with SRGClient(api_key="srgplus_...") as client:
profiles = client.hub_profiles.list()
contents = client.contents.filter(profiles[0].id)
The api_key can also be provided via the SRG_API_KEY environment variable:
export SRG_API_KEY=srgplus_...
client = SRGClient() # reads from env
Async
import asyncio
from srg import AsyncSRGClient
async def main():
async with AsyncSRGClient(api_key="srgplus_...") as client:
channels = await client.channels.list(hub_profile_id="hp-id")
# workspace_id is fetched lazily on first access:
ws_id = await client.get_workspace_id()
asyncio.run(main())
Per-request API keys (multi-tenant servers)
A single SRGClient / AsyncSRGClient can serve any number of workspaces from
one shared httpx connection pool. Bind the key per call instead of per
client:
from srg import SRGClient
client = SRGClient() # no eager bootstrap, no default key
# Option A — scoped clone (returns a thin wrapper that reuses the pool)
scoped = client.with_api_key("srgplus_workspace_a")
scoped.hub_profiles.list()
# Option C — context manager
with client.use_api_key("srgplus_workspace_b"):
client.hub_profiles.list()
The same patterns work on AsyncSRGClient:
async with AsyncSRGClient() as client:
async with client.use_api_key("srgplus_workspace_a"):
await client.hub_profiles.list()
scoped = client.with_api_key("srgplus_workspace_b")
await scoped.hub_profiles.list()
Implementation detail: an internal contextvars.ContextVar carries the active
key through the call stack, so with_api_key / use_api_key are safe under
asyncio and threaded servers. Each request adds its own Authorization
header — the underlying httpx.Client is shared.
When you call SRGClient(api_key=...) the eager way, that key is used as the
default for every request that doesn't have one bound — so existing single-key
code continues to work unchanged.
Configuration
| Parameter | Env var | Default |
|---|---|---|
api_key |
SRG_API_KEY |
required |
timeout |
— | 30.0 s |
Documentation
Full API reference and usage examples are in docs/:
| Section | Reference |
|---|---|
Client (SRGClient, AsyncSRGClient) |
docs/client.md |
| Users | docs/resources/users.md |
| Invitations | docs/resources/invitations.md |
| Permissions | docs/resources/permissions.md |
| Permission Groups | docs/resources/permission_groups.md |
| Hub Profiles | docs/resources/hub_profiles.md |
| Workspaces | docs/resources/workspaces.md |
| Assets | docs/resources/assets.md |
| Channels | docs/resources/channels.md |
| Contents | docs/resources/contents.md |
| Error handling | docs/exceptions.md |
License
MIT — see LICENSE.
Metadata
Release files for srgplus 0.2.4
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 |
|---|---|---|---|---|
| srgplus-0.2.4.tar.gz | 111.4 kB | Without provenance | Details for srgplus-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| srgplus-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for srgplus-0.2.4-py3-none-any.whl |
Total release size: 185.6 kB
Release files / srgplus-0.2.4.tar.gz
| Download URL | srgplus-0.2.4.tar.gz |
|---|---|
| Size | 111.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7cf7a377197a4e6eed3e9fea29e32ae8b90ccf1dce326c6163123ced8bc4fa1f
|
|
BLAKE2b-256 checksum How to use checksums |
c36d85a4fadb706f3611e815b2a4c6512fa7fa7f46d10945c3eb1ed9518262e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / srgplus-0.2.4-py3-none-any.whl
| Download URL | srgplus-0.2.4-py3-none-any.whl |
|---|---|
| Size | 74.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c310c026c8675b1e724f5b4ad2da2245287ae474d71e67f873f35eaa854207cc
|
|
BLAKE2b-256 checksum How to use checksums |
29916a231c357279aa183922e149df7b6af20f4ee7cb5b45aa021abb3c2b287b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for srgplus 0.2.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.