Python SDK
Package: indox-client, published on PyPI.
Requires Python 3.9 or newer and requests 2.28 or newer.
Notebooks: runnable examples for every part of the SDK, to read here or download.
Install
pip install --upgrade indox-clientSet up a client
Create an API key under Dashboard → API keys. It is shown once and starts with indox_. The
client reads it from INDOX_API_KEY, or takes it as api_key:
from indox_client import Indox
with Indox() as client: # reads INDOX_API_KEY
print(client.health.get())
with Indox(api_key="indox_...") as client:
...The base URL defaults to https://indox.org. Point it at your own instance with
Indox(base_url="https://api.example.com") or INDOX_BASE_URL. The context manager closes the
HTTP session when the block ends.
Convert a file
Conversions are asynchronous: submit, wait, download. client.conversion.wait follows a
conversion from any converter:
with Indox() as client:
job = client.images.convert("photo.png", target_format="webp")
client.conversion.wait(job["id"], timeout=120)
client.media.download(job["id"], "photo.webp")Fonts have a one-call helper that does all three steps:
with Indox() as client:
client.fonts.convert_and_download(
"MyFont.ttf", target_format="woff2", output_path="MyFont.woff2"
)More worked examples are in SDK Examples.
Resources
| Attribute | Covers | Reference |
|---|---|---|
client.health | Service health | |
client.images · client.videos · client.models | Media conversion | Media Conversion |
client.media | Media job status, downloads, batches, credits | Media Conversion |
client.conversion | get, wait and delete for any conversion id | Conversion Status |
client.pdf | Document conversion, retry, keep policy, save to files, email, form fields, pipelines, phone scan, e-signing | Document Conversion, E-signing |
client.pdf.forms | Public blank forms: list, fields, blank download URL, fill | Blank Forms |
client.pdf.ai | Ask, fill, detect fields, suggest comments, check numbers, classify, edit (credits) | PDF AI |
client.docs | Document job status, batches, credits | |
client.fonts | Formats, quota, upload, convert (with optional subsetting), validate, inspect, download | Font Conversion |
client.deck | AI slide decks (credits) | AI Slide Decks |
client.office | Office documents, import and export jobs (credits) | Office Editor |
client.webhooks | Create, list, update, delete, deliveries, test, rotate secret | Webhooks |
client.user | Sign-in and 2FA, profile, avatar, branding, integrations, preferences, storage files, usage, share links | Auth |
client.notifications | In-app notifications and email settings | Notifications |
client.storage | Connected Box, Dropbox, Google Drive and OneDrive | Cloud Storage |
client.audit | Your audit log, as a list or CSV | Audit Log |
client.billing | Credit balance, thresholds, rate card, subscription, usage by feature, plans, purchases | Billing |
Sign in for account operations
API keys cannot manage the account. These methods need a sign-in access token, passed per call
as access_token=: user.update_me, user.change_email, user.create_share,
user.delete_share, billing.purchase_initiate, billing.purchase_pay_as_you_go and
billing.storage_initiate.
from indox_client import Indox, MfaRequired
with Indox() as client:
try:
session = client.user.login(email="[email protected]", password="...")
except MfaRequired as challenge:
session = client.user.complete_2fa(challenge.mfa_token, input("2FA code: "))
token = session["external_token"]
client.user.update_me(first_name="Ada", access_token=token)client.user.refresh(refresh_token) rotates the access token, and client.user.logout() signs
out. The REST side of this flow is in Auth.
Errors, retries and timeouts
Failures raise typed exceptions, all importable from indox_client and all subclasses of
IndoxError. Errors that carry an HTTP response expose status_code and the parsed response:
| Exception | When |
|---|---|
BadRequestError | 400, and 422 validation errors |
AuthenticationError | 401; its subclass MfaRequired (with mfa_token) when login needs a 2FA code |
PaymentRequiredError | 402, not enough credits |
PermissionDeniedError | 403; its subclass ScopeError when the API key lacks the scope |
NotFoundError | 404, including ids you do not own |
GoneError | 410, an expired output or signing link |
RateLimitError | 429 after the retries ran out; retry_after holds the server hint in seconds |
InternalServerError | 5xx |
APIStatusError | Any other status, for example 409 |
APIConnectionError (the request never reached the API), ConversionError (a job failed
server-side) and ConversionTimeoutError (a wait ran past its timeout) have no HTTP status.
Catch IndoxError to cover everything.
from indox_client import Indox, BadRequestError
with Indox() as client:
try:
client.images.convert("photo.png", target_format="nope")
except BadRequestError as exc:
print(exc.status_code, exc.message, exc.response)The retry policy is the same in every SDK, see
Retries and rate limits. Tune it per client; the defaults are
the module constants DEFAULT_MAX_RETRIES, DEFAULT_MAX_RETRY_WAIT and DEFAULT_RETRY_BACKOFF,
and max_retries=0 turns retrying off:
Indox(max_retries=5, max_retry_wait=30.0, retry_backoff=1.0)Requests use a 5 s connect and 60 s read timeout by default. Change it with
Indox(timeout=(5.0, 120.0)).
Upgrading from 0.5
The API changes every client inherits are listed in Upgrading from 0.5. In Python:
user.update_me(...)takesusername,first_nameandlast_name. The email address moved touser.change_email(email, current_password=...).user.upload_file(path, related_task_id=None):s3_keyandstorage_already_trackedare gone.images,videosandmodels.convert: passinguser_idindataraisesValueError.pdf.submit_sign(token, otp)signs with the emailed code; callpdf.request_sign_otp(token)first.pdf.create_signing_session(path, emails=[...], title=None)uploads the PDF as multipart.docs.batch_collect(ids)anddocs.hide(ids)take a list of UUIDs.billing.task_completion: the server ignorescredit_costand theoutput_*fields; sendtask_type.fonts.health()andfonts.quota()return the new shapes (engines,storage,max_upload_mb, …).- Waits return a
partialconversion (some formats succeeded) instead of timing out.