Authentication¶
The first thing you will need to use bavapi
is a Fount API authentication token (a.k.a. key).
This token is a specific code that is assigned to you and is needed to confirm that you have access to the Fount data.
Getting a Fount API token¶
Please follow the instructions in the Authentication section of the Fount API documentation.
Warning
Do NOT share your API token publicly or with anyone else. That token is tied to your account exclusively. If somebody else needs a token, they should create their own from their account settings.
Recommended way to manage API keys¶
In order to keep your API token secure, you should avoid using your token directly in your code and applications. Instead, place the code in a .env
file at the top of your project directory, and use python-dotenv
to load the token into your environment:
Create a .env
file (note the leading dot) in the top level of your working directory, and write down your token:
Tip
The bavapi-gen-refs
command also uses the BAV_API_KEY
variable name.
To now use this file, you will need to install the python-dotenv
package:
Now, paste this code at the top of your Python files or Jupyter Notebooks:
import os
from dotenv import load_dotenv
load_dotenv() # (1)
TOKEN = os.environ["BAV_API_KEY"] # (2)
- Load variables from
.env
into the system's environment - Assign the
"BAV_API_KEY"
environment variable to ourTOKEN
local variable
Now you can use TOKEN
in your API requests: