Python SDK
PyPI package generated from the public OpenAPI spec.
Loading article…
Install the Python SDK when you prefer pip and generated API classes over hand-written requests calls. The package emailguard_sdk is built from the same OpenAPI spec as this reference (version 1.0.0).
pip install emailguard_sdk==1.0.0Use a virtual environment and pin the version in requirements.txt for reproducible deploys.
| Variable | Required | Description |
|---|---|---|
EMAILGUARD_API_KEY | Yes | Team-scoped live key (egsk_live_...) |
API_KEY is accepted as an alias in most clients.
Set the API host on Configuration.host if you are not targeting the default origin (https://api.emailguard.co).
import os
import emailguard_sdk
from emailguard_sdk.rest import ApiException
configuration = emailguard_sdk.Configuration(
host="https://api.emailguard.co",
)
configuration.api_key["Authorization"] = os.environ["EMAILGUARD_API_KEY"]
with emailguard_sdk.ApiClient(configuration) as api_client:
api = emailguard_sdk.TeamsApi(api_client)
try:
result = api.api_v1_team_get()
except ApiException as e:
raise SystemExit(e)Responses arrive as generated model objects wrapping HTTP JSON. Your API returns { "code", "data", "message" } — inspect the raw response or deserialize data when code is SUCCESS.
{
"code": "SUCCESS",
"data": { "..." : "..." },
"message": "OK"
}Check code before using data. On failure, log message and handle HTTP status from ApiException.
The generator splits 20 operations into resource-specific API classes (for example TeamsApi, MembersApi). Each class method corresponds to one route:
Open any endpoint in the sidebar and switch to the Python SDK tab for a route-specific sample.
import os
import emailguard_sdk
configuration = emailguard_sdk.Configuration(host="https://api.emailguard.co")
configuration.api_key["Authorization"] = os.environ["EMAILGUARD_API_KEY"]
configuration.api_key_prefix["Authorization"] = "Bearer"
with emailguard_sdk.ApiClient(configuration) as api_client:
teams = emailguard_sdk.TeamsApi(api_client)
# teams.api_v1_team_get()ApiException — carries HTTP status and response body; map 401/403 to credential or scope fixes.429 — pause and retry using Retry-After; see API rate limiting.