The official Python client library for the Dcipher Workflows API
Project description
Dcipher Workflows API Python library
The Dcipher Workflows Python library provides convenient access to the Dcipher Workflows API from any Python 3.7+ application. It offers both synchronous and asynchronous clients powered by httpx.
Documentation
The REST API documentation can be found on app.dcipheranalytics.com/workflows
Installation
pip install dcipher
Usage
import os
from dcipher import Dcipher
client = Dcipher(
# This is the default and can be omitted
api_key=os.environ.get("DCIPHER_API_KEY"),
)
client.run_flow(
flow_id="65cf2f3e..",
params={"param1": "...", "param2": "...."}, # param names are set by workflow user
save_path="output.json",
)
While you can provide an api_key keyword argument,
we recommend using python-dotenv
to add DCIPHER_API_KEY="my-dcipher-api-key" to your .env file
so that your API Key is not stored in source control.
Async usage
Simply import AsyncDcipher instead of Dcipher and use await with each API call:
import os
import asyncio
from dcipher import AsyncDcipher
client = AsyncDcipher(
# This is the default and can be omitted
api_key=os.environ.get("DCIPHER_API_KEY"),
)
async def main() -> None:
await client.run_flow(
flow_id="65cf2f3e..",
params={"param1": "...", "param2": "...."}, # param names are set by workflow user
save_path="output.json",
)
asyncio.run(main())
Functionality between the synchronous and asynchronous clients is otherwise identical.
Handling errors
When the API returns a non-success status code (that is, 4xx or 5xx
response), a subclass of APIStatusError is raised, containing an error message.
In case Timeout or Connection errors occur, the client auto-retries with exponential back-off using tenacity.
Error codes are as follows:
| Status Code | Error Type |
|---|---|
| 400 | BadRequestError |
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 404 | NotFoundError |
| 422 | UnprocessableEntityError |
| 429 | RateLimitError |
| >=500 | InternalServerError |
Retries
Certain errors are automatically retried by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors are all retried by default.
You can use the max_retries option to configure or disable retry settings.
Advanced
Logging
We use the standard library logging module.
You can enable logging by setting the environment variable DCIPHER_LOG to debug.
$ export DCIPHER_LOG=debug
Requirements
Python 3.7 or higher.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dcipher-0.3.4.tar.gz.
File metadata
- Download URL: dcipher-0.3.4.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.11.8 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ddc1804c78abbcb7d34b8e4e0e8da1801dfbbb22c2bc89e6fb2660fb820f2a2
|
|
| MD5 |
b15d1eee57b6c42a81ae9de8ae9eb276
|
|
| BLAKE2b-256 |
d753a6c19de765b2c7853d2f03aeb5b42c37ffe64705114cd043a9dccfc3afd0
|
File details
Details for the file dcipher-0.3.4-py3-none-any.whl.
File metadata
- Download URL: dcipher-0.3.4-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.11.8 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9425861017fad4932749eebeec51dd58ec275ceb2c6628cc074b6d84683e851d
|
|
| MD5 |
8b3287a800f3270ba3ec3808c3441872
|
|
| BLAKE2b-256 |
16fabc9c7fa19cfc36b4613f9653bb087ac825bb0af1d93234593b1f59bc906e
|