### Retrieve Law Content using POST /consult/legiPart Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This example shows how to fetch the full text of a law using the /consult/legiPart endpoint. It requires the law's text ID and a specific date to retrieve the correct version of the law. ```json { "date": 1561132975000, "textId": "LEGITEXT000038359719" } ``` -------------------------------- ### Query by Version Date in CODE Fund Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This example shows how to perform a search within the 'CODE' fund, specifically filtering by a version date. It targets articles containing the word 'responsabilite' and filters by the 'Code civil' with a version date of '2025-04-15'. ```json { "fond": "CODE_DATE", "recherche": { "champs": [ { "typeChamp": "ARTICLE", "criteres": [ { "typeRecherche": "UN_DES_MOTS", "valeur": "responsabilite", "operateur": "ET" } ], "operateur": "ET" } ], "filtres": [ { "facette": "NOM_CODE", "valeurs": [ "Code civil" ] }, { "facette": "DATE_VERSION", "singleDate": "2025-04-15" } ], "pageNumber": 1, "pageSize": 10, "operateur": "ET", "sort": "PERTINENCE", "typePagination": "DEFAUT" } } ``` -------------------------------- ### Search for an Expression in a Code Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This JSON example demonstrates searching for an expression within a legal code. It uses 'UN_DES_MOTS' for 'outrage a agent' and filters by 'Code pénal'. The 'typeRecherche' field can be adjusted to 'EXACTE' for precise phrase matching. ```json { "fond": "CODE_ETAT", "recherche": { "champs": [{ "typeChamp": "ARTICLE", "criteres": [{ "typeRecherche": "UN_DES_MOTS", "valeur": "outrage a agent", "operateur": "ET" } ], "operateur": "ET" } ], "filtres": [{ "facette": "TEXT_NOM_CODE", "valeurs": [ "Code pénal" ] } ], "pageNumber": 1, "pageSize": 10, "operateur": "ET", "sort": "PERTINENCE", "typePagination": "DEFAUT" } } ``` -------------------------------- ### Find Article in an Ordinance by Number and Date using POST /search Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This example demonstrates how to search for a specific article within an ordinance, identified by its number and a specific effective date. It uses the /search endpoint with detailed criteria including ordinance number, article number, and a date filter. ```json { "recherche": { "champs": [ { "typeChamp": "NUM", "criteres": [ { "typeRecherche": "EXACTE", "valeur": "58-1100", "operateur": "ET" } ], "operateur": "ET" }, { "typeChamp": "NUM_ARTICLE", "criteres": [ { "typeRecherche": "EXACTE", "valeur": "6 nonies", "operateur": "ET" } ], "operateur": "ET" } ], "filtres": [ { "facette": "DATE_VERSION", "singleDate": 1514802418000 } ], "pageNumber": 1, "pageSize": 10, "operateur": "ET", "sort": "PERTINENCE", "typePagination": "DEFAUT" }, "fond": "LODA_DATE" } ``` -------------------------------- ### Get Article Content using POST /consult/getArticle Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This snippet shows how to retrieve the content of a specific legal article by its ID using a POST request to the /consult/getArticle endpoint. It requires the article's unique identifier as input. ```json { "id": "LEGIARTI000033219357" } ``` -------------------------------- ### Légifrance API - Production Environment Usage Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Instructions on how to set up and use the Légifrance API in the production environment, including application creation and prerequisite steps. ```APIDOC ## How to Consume the API in Production ### Description This section details the steps required to consume the Légifrance API in the production environment, including manual application creation and ensuring prerequisite validations are completed. ### Steps 1. **Create a Production Application:** Manually create a production application by navigating to the 'Applications' tab and clicking 'Créer une application'. 2. **Validate CGUs:** Ensure you have completed the CGU validation steps as described in section 1.3.1. 3. **Select API Consumption:** Indicate within your production application that you wish to consume the Légifrance API, as described in section 1.3.2. ### Benefits Following these steps allows you to use the production URLs and benefit from higher quotas. ``` -------------------------------- ### Official Journal Content Retrieval Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This API allows retrieving content from the Official Journals (JO). It involves a multi-step process: first, getting the container ID (JORFCONT), then the text identifiers (JORFTEXT), and finally the actual content. ```APIDOC ## Official Journal Content Retrieval API ### Description This API provides a multi-step process to retrieve content from the Official Journals (JO). It allows fetching container IDs, text identifiers, and the final content of JO publications. ### Method POST ### Endpoints 1. **/consult/lastNJo** 2. **/consult/jorfCont** 3. **/consult/jorf** ### Step 1: Retrieve JORFCONT (Official Journal Container ID) #### Endpoint `/consult/lastNJo` #### Description Retrieves the JORFCONT identifier for a specified number of recent Official Journals. #### Parameters ##### Request Body - **nbElement** (integer) - Required - The number of recent JOs to retrieve container IDs for. Must be less than 2500. ##### Request Example ```json { "nbElement": 5 } ``` ##### Response (200) - **[List of JORFCONT identifiers]** ### Step 2: Retrieve JORFTEXT (Official Journal Text Identifiers) #### Endpoint `/consult/jorfCont` #### Description Retrieves JORFTEXT identifiers for texts within a specific Official Journal container or a date range. #### Parameters ##### Request Body - **highlightActivated** (boolean) - Optional - Whether to activate highlighting. - **id** (string) - Required - The JORFCONT identifier obtained from Step 1. - **pageNumber** (integer) - Required - The current page number. - **pageSize** (integer) - Required - The number of results per page. *Note: This endpoint can also accept a date range to retrieve JORFCONTs for a specific period.* ##### Request Example ```json { "highlightActivated": true, "id": "JORFCONT000022470431", "pageNumber": 1, "pageSize": 10 } ``` ##### Response (200) - **[List of JORFTEXT identifiers]** ### Step 3: Retrieve Official Journal Content #### Endpoint `/consult/jorf` #### Description Retrieves the actual content of Official Journal texts using the JORFTEXT identifiers obtained from Step 2. #### Parameters ##### Request Body - **highlightActivated** (boolean) - Optional - Whether to activate highlighting. - **id** (string) - Required - The JORFCONT identifier (can also use JORFTEXT identifier). - **pageNumber** (integer) - Required - The current page number. - **pageSize** (integer) - Required - The number of results per page. *Note: This endpoint is more relevant than `getJoWithNor` as not all texts have a NOR identifier.* *Older JOs (before June 2004) may not have HTML versions available via this API.* ##### Request Example ```json { "highlightActivated": true, "id": "JORFCONT000022470431", "pageNumber": 1, "pageSize": 10 } ``` ##### Response (200) - **[Content of the Official Journal texts]** ``` -------------------------------- ### Consommer l'API Légifrance avec un jeton d'authentification Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Pour consommer l'API Légifrance, il est nécessaire d'inclure l'en-tête 'Authorization: Bearer ' dans chaque requête. Pour les requêtes POST, les en-têtes 'accept: application/json' et 'Content-Type: application/json' doivent également être ajoutés. ```bash curl -is -H 'Authorization: Bearer ojECscMjYOh215MN6dUvAI3SOmhOa0nbg5R4tYvDWhZu5HB5ejMG74' -X GET https://sandbox-api.piste.gouv.fr/dila/legifrance/lf-engine-app/list/ping ``` -------------------------------- ### Requête POST /search pour obtenir un article par ID et date (JSON) Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Cet exemple montre le corps d'une requête POST à l'endpoint /search pour trouver un article spécifique dans un code donné, en utilisant son numéro d'article et une date de version. Il spécifie les champs de recherche, les filtres par nom de code et date, ainsi que les options de pagination et de tri. ```json { "recherche": { "champs": [ { "typeChamp": "NUM_ARTICLE", "criteres": [ { "typeRecherche": "EXACTE", "valeur": "L36-11", "operateur": "ET" } ], "operateur": "ET" } ], "filtres": [ { "facette": "NOM_CODE", "valeurs": [ "Code des postes et des communications électroniques" ] }, { "facette": "DATE_VERSION", "singleDate": 1514802418000 } ], "pageNumber": 1, "pageSize": 10, "operateur": "ET", "sort": "PERTINENCE", "typePagination": "ARTICLE" }, "fond": "CODE_DATE" } ``` -------------------------------- ### Obtenir un jeton OAuth2.0 avec PISTE Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Cette requête permet d'obtenir un jeton d'accès OAuth2.0 en utilisant le flux Client Credentials. Elle nécessite un client_id et un client_secret générés sur le portail PISTE. La réponse contient le jeton d'accès et sa durée de validité. ```http POST https://sandbox-oauth.piste.gouv.fr/api/oauth/token HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/x-www-form-urlencoded Content-Length: 140 Host: sandbox-oauth.piste.gouv.fr Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) grant_type=client_credentials&client_id= &client_secret=&scope=openid ``` -------------------------------- ### Cross-Search of Words in Consolidated Texts Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This example illustrates how to perform a cross-search for multiple keywords within consolidated texts. It searches for documents in the 'LODA_DATE' fund where 'mineur' and 'travail' appear within a proximity of 2 words. The 'typeChamp' is set to 'ALL' to search across all fields. ```json { "fond": "LODA_DATE", "recherche": { "champs": [{ "criteres": [{ "criteres": [{ "typeRecherche": "UN_DES_MOTS", "valeur": "mineur", "operateur": "ET" } ], "operateur": "ET", "proximite": 2, "typeRecherche": "UN_DES_MOTS", "valeur": "travail" } ], "operateur": "ET", "typeChamp": "ALL" } ], "fromAdvancedRecherche": false, "operateur": "ET", "pageNumber": 1, "pageSize": 10, "secondSort": "ID", "sort": "SIGNATURE_DATE_DESC", "typePagination": "DEFAUT" } } ``` -------------------------------- ### Récupérer un jeton OAuth2.0 avec PISTE (Réponse) Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Exemple de réponse lors de la requête pour obtenir un jeton OAuth2.0. La réponse est au format JSON et contient le jeton d'accès ('access_token'), le type de jeton ('token_type'), la durée d'expiration ('expires_in') et le scope. ```json { "access_token": "th2uv3lq9zY2vAoth59QpYtCSID1iWn0AG6XhnjgAP54eoY1440vp3", "token_type": "Bearer", "expires_in": 3600, "scope": "openid" } ``` -------------------------------- ### Obtenir un jeton OAuth2.0 Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Permet d'obtenir un jeton d'accès OAuth 2.0 en utilisant le flux Client Credentials avec PISTE. Ce jeton est nécessaire pour authentifier les requêtes à l'API Légifrance. ```APIDOC ## POST /oauth/token ### Description Obtient un jeton d'accès OAuth 2.0 pour l'authentification auprès de l'API Légifrance. ### Method POST ### Endpoint `https://sandbox-oauth.piste.gouv.fr/api/oauth/token` ### Parameters #### Query Parameters - **grant_type** (string) - Required - Doit être `client_credentials`. - **client_id** (string) - Required - L'ID client généré sur le portail. - **client_secret** (string) - Required - Le secret client généré sur le portail. - **scope** (string) - Required - Doit être `openid`. ### Request Example ``` POST https://sandbox-oauth.piste.gouv.fr/api/oauth/token HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/x-www-form-urlencoded Content-Length: 140 Host: sandbox-oauth.piste.gouv.fr Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) grant_type=client_credentials&client_id=&client_secret=&scope=openid ``` ### Response #### Success Response (200) - **access_token** (string) - Le jeton d'accès JWT. - **token_type** (string) - Le type de jeton, généralement "Bearer". - **expires_in** (integer) - La durée de validité du jeton en secondes. - **scope** (string) - Le scope accordé au jeton. #### Response Example ```json { "access_token": "th2uv3lq9zY2vAoth59QpYtCSID1iWn0AG6XhnjgAP54eoY1440vp3", "token_type": "Bearer", "expires_in": 3600, "scope": "openid" } ``` ``` -------------------------------- ### Consommer l'API Légifrance Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Instructions sur la manière d'ajouter l'en-tête d'autorisation pour consommer l'API Légifrance et les en-têtes supplémentaires requis pour les requêtes POST. ```APIDOC ## Consommer l'API ### Description Pour consommer l'API Légifrance, il est nécessaire d'inclure l'en-tête `Authorization` avec le jeton d'accès obtenu. Pour les requêtes POST, des en-têtes supplémentaires sont requis. ### Method GET, POST ### Endpoint `https://sandbox-api.piste.gouv.fr/dila/legifrance/lf-engine-app/*` (Exemple pour GET) ### Parameters #### Request Headers - **Authorization** (string) - Required - Doit être au format `Bearer `. - **Accept** (string) - Required pour POST - Doit être `application/json`. - **Content-Type** (string) - Required pour POST - Doit être `application/json`. ### Request Example (GET) ```bash curl -is -H 'Authorization: Bearer ojECscMjYOh215MN6dUvAI3SOmhOa0nbg5R4tYvDWhZu5HB5ejMG74' -X GET https://sandbox-api.piste.gouv.fr/dila/legifrance/lf-engine-app/list/ping ``` ### Request Example (POST) ```bash curl -is -H 'Authorization: Bearer ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -X POST https://sandbox-api.piste.gouv.fr/dila/legifrance/lf-engine-app/search \ -d '{"query": "some query"}' ``` ``` -------------------------------- ### POST /search - Retrieve Article by ID and Date Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This endpoint allows you to search for a specific article within a code, given its ID and a specific version date. It returns the article identifier. ```APIDOC ## POST /search - Retrieve Article by ID and Date ### Description This endpoint is used to retrieve the identifier of an article in force on a given date, for a code where the ID is known. It utilizes a POST request with a structured JSON body to specify search criteria. ### Method POST ### Endpoint `/search` ### Parameters #### Request Body - **recherche** (object) - Required - Search criteria object. - **champs** (array) - Required - Array of field search criteria. - **typeChamp** (string) - Required - Type of field (e.g., `NUM_ARTICLE`). - **criteres** (array) - Required - Array of search conditions for the field. - **typeRecherche** (string) - Required - Type of search (e.g., `EXACTE`). - **valeur** (string) - Required - The value to search for (e.g., article number). - **operateur** (string) - Required - Logical operator (e.g., `ET`). - **operateur** (string) - Required - Logical operator for the field. - **filtres** (array) - Required - Array of filter criteria. - **facette** (string) - Required - Facet name (e.g., `NOM_CODE`, `DATE_VERSION`). - **valeurs** (array) - Required (if `facette` is `NOM_CODE`) - Array of values for the facet (e.g., code name). - **singleDate** (number) - Required (if `facette` is `DATE_VERSION`) - Timestamp for the version date. - **pageNumber** (integer) - Required - The page number for pagination. - **pageSize** (integer) - Required - The number of results per page. - **operateur** (string) - Required - Logical operator for the overall search. - **sort** (string) - Required - Sorting order (e.g., `PERTINENCE`). - **typePagination** (string) - Required - Type of pagination (e.g., `ARTICLE`). - **fond** (string) - Required - Specifies the data source or type (e.g., `CODE_DATE`). ### Request Example ```json { "recherche": { "champs": [ { "typeChamp": "NUM_ARTICLE", "criteres": [ { "typeRecherche": "EXACTE", "valeur": "L36-11", "operateur": "ET" } ], "operateur": "ET" } ], "filtres": [ { "facette": "NOM_CODE", "valeurs": [ "Code des postes et des communications électroniques" ] }, { "facette": "DATE_VERSION", "singleDate": 1514802418000 } ], "pageNumber": 1, "pageSize": 10, "operateur": "ET", "sort": "PERTINENCE", "typePagination": "ARTICLE" }, "fond": "CODE_DATE" } ``` ### Response #### Success Response (200) - **articleId** (string) - The unique identifier of the retrieved article. #### Response Example ```json { "articleId": "some_article_identifier" } ``` ``` -------------------------------- ### Retrieve Article using POST /consult/getArticle Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Once the article identifier (LEGIARTI) is obtained, this method is used to retrieve the full content of the article. It requires a JSON payload containing the article's ID. The output is the article's content in JSON format. ```json { "id": "LEGIARTI000006528277" } ``` -------------------------------- ### Find Law by Number and Date using POST /search Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api This snippet demonstrates how to search for a law by its number and a specific effective date. It uses the /search endpoint, providing the law number and filtering by date and legal status (in force). ```json { "recherche": { "champs": [ { "typeChamp": "NUM", "criteres": [ { "typeRecherche": "EXACTE", "valeur": "2019-290", "operateur": "ET" } ], "operateur": "ET" } ], "filtres": [ { "facette": "DATE_VERSION", "singleDate": 1561132975000 }, { "facette": "TEXT_LEGAL_STATUS", "valeur": "VIGUEUR" } ], "pageNumber": 1, "pageSize": 10, "operateur": "ET", "sort": "PERTINENCE", "typePagination": "DEFAUT" }, "fond": "LODA_ETAT" } ``` -------------------------------- ### POST /consult/getArticle - Retrieve Article Content Source: https://www.legifrance.gouv.fr/contenu/menu/pied-de-page/foire-aux-questions-api Once the LEGIARTI identifier is obtained, this endpoint is used to retrieve the full content of the article. ```APIDOC ## POST /consult/getArticle ### Description Retrieve the content of a legal article using its unique identifier. ### Method POST ### Endpoint /consult/getArticle ### Parameters #### Request Body - **id** (string) - Required - The unique identifier of the article (e.g., LEGIARTI000006528277). ### Request Example ```json { "id": "LEGIARTI000006528277" } ``` ### Response #### Success Response (200) - **content** (string) - The full content of the legal article. #### Response Example ```json { "content": "[Article content here...]" } ``` ```