Skip to content
This repository was archived by the owner on Feb 10, 2026. It is now read-only.

jurisearch/LegifranceAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LegifranceAPI

Repository Overview

The goal of this repository is to provide all the tools to list and download jurisprudence texts published on Légifrance.

This is achieved by leveraging the API provided by Légifrance. However, due to the rate limiters the API is subject to, it is likely not possible to download all the information in a single run. For this reason, the script implements significant redundance to retry failed requests as well as to save as much as possible partial results.

It is advisable to run these tools on a schedule, just verifying that two processes are not running simultaneoulsy (this usage is untested).

Repository Structure

This repository contains the following files and directories:

  • run.py: Main Python script used to run the tools.
  • legifrance_api: Directory collecting all additional Python scripts and custom modules needed to run the tools.
  • .gitignore: Gitignore file for this repository.
  • requirements.txt: PIP requirements file to install required packages.
  • README.md: The Readme file you are currently reading.

Getting Started

0) Python Environment

The Python enviroment used for this repository was purposefully kept as simple as possible, with minimal dependencies.

An environment containing the required packages with compatible versions can be created as follows:

conda create -n legifrance_api python==3.12.4
conda activate legifrance_api
pip install -r requirements.txt

1) OAuth Credentials

OAuth is needed to access the Légifrance API. The official instructions on how to generate the id and secret for OAuth are provided here.

In summary:

  1. Need to create an account on the PISTE portal.
  2. Need to create a new application with environment "PRODUCTION".
  3. Need to accept the terms of service for the Légifrance API within that application.
  4. Obtain an OAuth id and secret from the portal.

It is advised to re-generate new credentials and invalidate the existing ones every 6-12 months.

2) Setting environmental variables

The following environmental variables need to be set before the script can be run: LEGIFRANCE_API_CLIENT_ID, LEGIFRANCE_API_CLIENT_SECRET, POSTGRES_HOST, POSTGRES_DB_NAME, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_PORT.

Do not put these variables in a file that gets pushed to an online repository.

3) Run

To run the Python script, simply activate the correct conda environment and, from the same directory as the run.py file run:

python run.py

Line arguments can be provided to the above command to change the behaviour of the script. An exaustive list of them can be found by running python run.py -h.

Of particular interest, these line arguments:

  • [--monitor | --no-monitor] : This boolean flag activates or deactivates the search of new jurisprudence texts from the online database.
  • [--content | --no-content] : This boolean flag activates or deactivates the retrieval of identified jurisprudence texts contents from the online database.

These arguments allow to tell the script to only run only the search or only the content retrieval. By default, the scipt will run both steps.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages