Authentication¶
The Crux Python Client interacts with the Crux API, which requires an API key. Your API key can be retrieved from your Profile within the Crux web application.
Function arguments¶
For basic scripts you can set the API key with the api_key
argument when instantiating the Crux client.
from crux import Crux
conn = Crux(api_key="YOUR_API_KEY")
print(conn.whoami())
The optional argument api_host
can be used to set a different API host, the default is https://api.cruxinformatics.com
.
from crux import Crux
conn = Crux(api_key="YOUR_API_KEY", api_host="https://api.cruxinformatics.com")
print(conn.whoami())
Environment variables¶
In production environments, or on your workstation, you can an environment variable to set the API key.
Shell:
export CRUX_API_KEY="YOUR_API_KEY"
Python:
from crux import Crux
conn = Crux()
print(conn.whoami())
The API host can optionally be set, it defaults to https://api.cruxinformatics.com
.
Shell:
export CRUX_API_KEY="YOUR_API_KEY"
export CRUX_API_HOST="https://api.cruxinformatics.com"
Python:
from crux import Crux
conn = Crux()
print(conn.whoami())