Python SDK configuration
The Socifyr constructor reads credentials from arguments first and environment variables second.
from socifyr import Socifyr
client = Socifyr(
api_key="sk_...",
workspace_id="ws_...",
base_url="https://api.socifyr.com/api", # optional
timeout=30.0, # optional, seconds
)What arguments does the constructor accept?
| Argument | Type | Default | Environment variable |
|---|---|---|---|
api_key | str | None | none | SOCIFYR_API_KEY |
workspace_id | str | None | none | SOCIFYR_WORKSPACE_ID |
base_url | str | None | https://api.socifyr.com/api | SOCIFYR_API_URL |
timeout | float | 30.0 | none |
base_url and timeout are keyword-only. If no API key is found, the constructor raises ValueError.
workspace_id is optional in the Python client. If you omit it, no X-Workspace-Id header is sent and the API uses your first workspace membership (see workspace header). Set it explicitly when you belong to more than one workspace.
Are requests retried?
No. The Python client makes one attempt per call. A network failure raises SocifyrError with status of None. The timeout applies to each request. For retries, wrap calls yourself and only re-send reads, because a timed-out POST may already have been accepted.
import time
from socifyr import Socifyr, SocifyrError
client = Socifyr()
def get_status_with_retry(request_id, attempts=3):
for i in range(attempts):
try:
return client.uploads.get_status(request_id)
except SocifyrError as err:
if err.status is not None and err.status < 500:
raise
time.sleep(2 ** i)
raise RuntimeError("status check kept failing")Can I use a custom HTTP session?
The client creates its own requests.Session and keeps it in a private attribute. There is no public hook for proxies or custom adapters. If you need one, call the REST API with your own requests session.