CypherMed Cloud Python SDK
This Python package serves as an interface for the CypherMed Cloud plaform.
Related links:
Installation
Assuming that you have a supported version of Python installed, you can first set up your environment with:
python -m venv .venv
...
. .venv/bin/activate
Then, you can install the latest version of cyphermed from PyPI with:
pip install cyphermed
Usage
No further configuration necessary, you are ready to start using the CypherMed Cloud Python SDK.
First, create a reusable client:
from cyphermed import Client
client = Client(base_url="https://api.cyphermed.cloud")
If the endpoints you're going to hit require authentication, use AuthenticatedClient
instead:
from cyphermed import AuthenticatedClient
client = AuthenticatedClient(base_url="https://api.cyphermed.cloud", token="YOUR_TOKEN")
All models, including query parameters, request bodies, and response bodies, are found in the cyphermed.models
module. For example, here is how you might prepare the request body for a new user:
from cyphermed.models.create_user_body import CreateUserBody
body = CreateUserBody(email="example@gmail.com", first_name="John", last_name="Doe")
Now we can call the new user endpoint using the client we created, and the body we prepared:
from cyphermed.api.users import create_user
new_user_info = create_user.sync(client=client, body=body)
new_user_id = new_user_info.user.id
Or to do the same thing with the async version:
new_user_info = await create_user.asyncio(client=client, body=body)
If we need more information about the response, we can use the _detailed
version of the function:
from cyphermed.api.users import create_user
from cyphermed.types import Response
new_user_info = create_user.sync(client=client, body=body)
status_code = new_user_info.status_code
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="YOUR_TOKEN_HERE",
verify_ssl="/path/to/certificate_bundle.pem",
)
You can also disable certificate validation altogether, but beware that this is a security risk and not recommended.
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="YOUR_TOKEN_HERE",
verify_ssl=False
)
There are more settings on the generated Client
class which let you control more runtime behavior, check out the docstring on that class for more info.
Things to know:
-
Every path/method combo becomes a Python module with four functions:
sync
: Blocking request that returns parsed data (if successful) orNone
sync_detailed
: Blocking request that always returns aRequest
, optionally withparsed
set if the request was successful.asyncio
: Likesync
but async instead of blockingasyncio_detailed
: Likesync_detailed
but async instead of blocking
-
All path/query params, and bodies become method arguments.
-
If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
-
Any endpoint which did not have a tag will be in
cyphermed.api.default
Getting Help
If you have any questions or need help, please contact us at support@cyphermed.cloud