Skip to content

Authentication#

Create a QCentroidClient with your QCentroid API key:

You can generate or obtain your API key from your user profile page in QCentroid.

from qcentroid_sdk import QCentroidClient

client = QCentroidClient(
    api_key="your-api-key",
)

The SDK authenticates automatically when it needs to make the first API call.

Use environment variables#

The client can also read configuration from environment variables:

  • QCENTROID_API_KEY
  • QCENTROID_TOKEN
  • QCENTROID_ENVIRONMENT
  • QCENTROID_BASE_URL

Example:

from qcentroid_sdk import QCentroidClient

client = QCentroidClient()

If those environment variables are set, the client will use them automatically.

Default environment#

If you do not provide an environment, the SDK uses sandbox by default.

client = QCentroidClient(
    api_key="your-api-key",
)

This is equivalent to:

client = QCentroidClient(
    environment="sandbox",
    api_key="your-api-key",
)

Use a different environment#

For example, to connect to the development environment:

client = QCentroidClient(
    environment="dev",
    api_key="your-api-key",
)

Use an existing token#

If you already have an access token, you can initialize the client directly with it:

client = QCentroidClient(token="your-access-token")

Close the client#

The SDK manages an underlying HTTP client. You can close it explicitly:

client.close()

Or use a context manager:

with QCentroidClient(
    api_key="your-api-key",
) as client:
    jobs = client.jobs.list(limit=5)