API Key#
Each workspace you are part of provides you with an API key that is used to associate and authorize your use of the
tlc
Python package and 3LC Object Service with that workspace. Your API key may be
found on the API keys page of your 3LC account. Note that API keys are unique to each
user of a workspace and should not be shared with others.
Providing Your API Key#
You can provide your API key for use with 3LC in several different ways. The following sections are ordered by how common the approach is. There is a section down below that explains the precedence of API key sources.
Using the 3lc login
Command#
The 3lc login
command generally verifies your API key and then stores it in a file in the 3LC configuration directory
on your system so that it can be used each time the tlc
package or the Object Service is used. See
here for the default location of the API key file.
Make sure to exchange the API key placeholder <api_key>
with your actual API key in the snippet below before
executing.
3lc login <api_key>
By default, the 3lc login
command verifies your API key with 3LC. You can have the command skip verification and just
write to the API key file by using the --no-verify
option. However, the key will always still be verified when using
the tlc
package or the Object Service.
It is possible to leave off the <api_key>
argument to the 3lc login
command. In that case, you will usually be
prompted to provide your API key interactively. It will then be verified (unless --no-verify
was used) and stored in
the API key file. You will not be prompted to provide an API key if the TLC_API_KEY
environment variable is set (see
the next section) because it takes precedence over the API key file anyway. Instead, the API key value set in the
environment variable will be verified with 3LC.
Using the TLC_API_KEY
Environment Variable#
You can also provide your API key via the TLC_API_KEY
environment variable. This may be particularly useful in
automation scenarios such as scripting or CI/CD workflows.
set TLC_API_KEY=<api_key>
export TLC_API_KEY=<api_key>
Using a 3lc Command-Line Argument#
For commands using the 3lc
CLI, you can provide your API key as a command-line argument, though this is uncommon in
practice. For example:
3lc --api-key <api_key> <command>
When Prompted by the tlc
Package or Object Service#
If you do not provide your API key using one of the methods above, then you will be prompted to provide it the first
time you import tlc
in Python code or start the Object Service. Once provided, your API key will be stored in a file
in the 3LC configuration directory on your system so that it can be used each time the tlc
package or the Object
Service is used, just as when using 3lc login
. See here for the default location of the API
key file.
API Key Precedence#
The precedence of API key sources is as follows:
3lc command-line argument > TLC_API_KEY environment variable > API key file > prompt
As described above, both the 3lc login
command and the prompt generally write your API key to the API key file, which
is then available in subsequent uses of the tlc
package and the Object Service.