Skip to content

Python SDK configuration ​

The Socifyr constructor reads credentials from arguments first and environment variables second.

python
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? ​

ArgumentTypeDefaultEnvironment variable
api_keystr | NonenoneSOCIFYR_API_KEY
workspace_idstr | NonenoneSOCIFYR_WORKSPACE_ID
base_urlstr | Nonehttps://api.socifyr.com/apiSOCIFYR_API_URL
timeoutfloat30.0none

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.

python
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.

Next steps ​