Skip to content

Authentication💡

The 3Di API uses personal api keys to authenticate users. They need to be included as an HTTP authentication header with all requests sent to the 3Di API.

A personal access key can be created here: https://management.3di.live/personal_api_keys

Using the ThreediApi💡

When using the ThreediApi two settings need to be in place to make requests to the 3Di API

  • the hostname
  • the personal api key

These settings should be stored in environment variables, or in a .env file.

# A sample .env file could look like this
THREEDI_API_HOST=https://api.3di.live
THREEDI_API_PERSONAL_API_TOKEN=your_personal_api_key_here

The file path can then be passed to the ThreediApi on initialisation.

from threedi_api_client.api import ThreediApi
from threedi_api_client.versions import V3Api

env_file = "<path>/.env"
api_client: V3Api = ThreediApi(env_file)

# Get list of simulations
api_client.simulations_list()

# or as context manager
with ThreediApi(env_file) as api_client:
    api_client: V3Api
    api_client.simulations_list()

Alternatively, you can create a config dictionary and pass that to the ThreediApi

from threedi_api_client.api import ThreediApi
from threedi_api_client.versions import V3Api

API_HOST = "https://api.3di.live"
config = {
    "THREEDI_API_HOST": API_HOST,
    "THREEDI_API_PERSONAL_API_TOKEN": your_personal_api_key_here
}

api_client: V3Api = ThreediApi(config=config)

# Get list of simulations
api_client.simulations_list()