Configure API credentials
Two options — environment variables (recommended) or a manual
ApiConfig.
1. Environment variables (.env)
Section titled “1. Environment variables (.env)”Create a .env file at the project root:
LEGIFRANCE_CLIENT_ID=your_client_idLEGIFRANCE_CLIENT_SECRET=your_client_secretThen:
from pylegifrance import LegifranceClient
client = LegifranceClient() # reads .env via python-dotenv2. Manual configuration
Section titled “2. Manual configuration”Useful when keys come from a vault or an external system:
from pylegifrance import LegifranceClientfrom pylegifrance.config import ApiConfig
client = LegifranceClient( ApiConfig(client_id="...", client_secret="..."))Credentials are mandatory at instantiation; otherwise an error is raised.