Skip to content

Configure API credentials

Two options — environment variables (recommended) or a manual ApiConfig.

Create a .env file at the project root:

Fenêtre de terminal
LEGIFRANCE_CLIENT_ID=your_client_id
LEGIFRANCE_CLIENT_SECRET=your_client_secret

Then:

from pylegifrance import LegifranceClient
client = LegifranceClient() # reads .env via python-dotenv

Useful when keys come from a vault or an external system:

from pylegifrance import LegifranceClient
from pylegifrance.config import ApiConfig
client = LegifranceClient(
ApiConfig(client_id="...", client_secret="...")
)

Credentials are mandatory at instantiation; otherwise an error is raised.