Skip to content

LegifranceClient

LegifranceClient is the single entry point for all calls to the Legifrance API. It wraps:

Two ways:

from pylegifrance import LegifranceClient
# 1. From the environment (LEGIFRANCE_CLIENT_ID / _SECRET in .env)
client = LegifranceClient()
# 2. Manually, with an explicit ApiConfig
from pylegifrance.config import ApiConfig
client = LegifranceClient(
ApiConfig(client_id="...", client_secret="...")
)

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

with client.session_context():
... # API calls

The context closes the session cleanly on exit.

MethodRole
call_api(route, data)POST JSON to route
get(route)GET to route
ping(route="consult/ping")Check API reachability
update_api_keys(...)Change credentials at runtime

For the full signature, see /en/references/client.