npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aismarttalk/legifrance-sdk

v1.0.2

Published

TypeScript SDK for the Legifrance API - Access French legal texts, jurisprudence, and codes with full type safety

Readme

📚 Legifrance SDK

TypeScript SDK for the Legifrance API

Made with ❤️ by AI Smarttalk

npm version TypeScript License: MIT npm downloads

🚀 Features

  • Full TypeScript support with autocomplete
  • OAuth2 authentication handled automatically
  • Sandbox & Production environments
  • Complete LODA search with all filters (dates, natures, legal status)
  • Clean & simple API

📦 Installation

npm install @aismarttalk/legifrance-sdk

or with yarn:

yarn add @aismarttalk/legifrance-sdk

🔧 Quick Start

import { LegifranceClient, Nature } from '@aismarttalk/legifrance-sdk';

const client = new LegifranceClient({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  environment: 'sandbox', // or 'production'
});

await client.initialize();

// Search in LODA
const result = await client.searchLoda('environnement', {
  pageSize: 10,
  natures: [Nature.DECRET, Nature.ARRETE],
  datePublication: { start: '2025-01-01', end: '2025-12-31' },
});

console.log(`Found ${result.totalResultNumber} results`);

📋 Covered Endpoints

| Endpoint | Method | Description | Status | |----------|--------|-------------|--------| | /consult/ping | ping() | Test API connectivity | ✅ Working | | /list/loda | listLoda() | List LODA texts | ✅ Working | | /search (LODA) | searchLoda() | Search LODA with filters | ✅ Working | | /search (JURI) | searchJuri() | Search jurisprudence with filters | ✅ Working | | /consult/loda | consultLoda() | Consult a LODA text | ✅ Working | | /consult/loda/version | consultLodaVersion() | Consult specific version | ✅ Working | | /consult/loda/versions | listLodaVersions() | List text versions | ✅ Working |

🔍 Search Parameters

LODA Search (LOI, ORDONNANCE, DECRET, ARRETE)

The searchLoda() method supports all parameters from the official Python wrapper:

await client.searchLoda('query text', {
  // Pagination
  pageSize: 10,
  pageNumber: 1,
  
  // Search parameters
  textId: 'LEGITEXT000006074220',
  champ: 'ALL', // 'ALL' | 'TEXTE' | 'TITLE' | 'NUM'
  typeRecherche: 'TOUS_LES_MOTS_DANS_UN_CHAMP', // Search type
  
  // Filters
  fond: 'LODA_DATE', // 'LODA_DATE' | 'LODA_ETAT'
  natures: [Nature.LOI, Nature.DECRET, Nature.ARRETE],
  
  // Date filters
  dateSignature: '2024-01-01', // or { start: '...', end: '...' }
  datePublication: { start: '2025-01-01', end: '2025-12-31' },
});

JURI Search (Jurisprudence)

The searchJuri() method supports comprehensive jurisprudence search with filters:

await client.searchJuri('contrat de travail', {
  // Pagination
  pageSize: 5,
  pageNumber: 1,
  
  // Publication filter
  publicationBulletin: [PublicationStatus.PUBLIER], // or NON_PUBLIER, PUBLIER_EXTRAIT
  
  // Juridiction filter
  juridictionJudiciaire: ['Cour de cassation'], // or "Juridictions d'appel", etc.
  
  // Date filter
  dateStart: '2024-01-01',
  dateEnd: '2024-12-31',
  dateFacet: 'DATE_DECISION', // or 'DATE_PUBLI'
  
  // Formation filter (for Cour de cassation)
  formation: ['Chambre sociale'], // or 'Chambre commerciale', 'Première chambre civile', etc.
  
  // Court of appeal location (only for "Juridictions d'appel")
  courAppel: ['Paris'],
  
  // Search configuration
  field: 'ALL', // 'ALL' | 'TEXTE' | 'TITLE'
  searchType: 'UN_DES_MOTS', // or 'TOUS_LES_MOTS_DANS_UN_CHAMP', 'EXACTE'
  sort: SortJuri.PERTINENCE, // or DATE_DESC, DATE_ASC
});

Return type: Fully typed JuriSearchResponse with JuriSearchResult[] - no any types! ✨

📖 Available Constants

import { 
  // Common
  Nature,              // LOI, DECRET, ARRETE, ORDONNANCE, etc.
  Fond,                // LODA_DATE, LODA_ETAT, CODE_DATE, JURI, etc.
  TypeChamp,           // ALL, TEXTE, TITLE, NUM, etc.
  Operateur,           // ET, OU, SAUF, NEAR, etc.
  Facette,             // DATE_VERSION, TEXT_LEGAL_STATUS, etc.
  Sort,                // PUBLICATION_DATE_DESC, SIGNATURE_DATE_ASC, etc.
  
  // LODA-specific
  LodaSearchRequest,   // Typed request
  LodaSearchResponse,  // Typed response
  LodaSearchResult,    // Typed result
  
  // JURI-specific
  SortJuri,            // PERTINENCE, DATE_DESC, DATE_ASC
  PublicationStatus,   // PUBLIER, NON_PUBLIER, PUBLIER_EXTRAIT
  FacettesJuri,        // CASSATION_TYPE_PUBLICATION_BULLETIN, JURIDICTION_JUDICIAIRE, etc.
  JuriSearchResponse,  // Typed response
  JuriSearchResult,    // Typed result
} from 'legifrance-sdk';

🛠️ Environment Configuration

Create a .env file:

CLIENT_ID=your_client_id
CLIENT_SECRET=your_client_secret

Then use:

import 'dotenv/config';

const client = new LegifranceClient({
  clientId: process.env.CLIENT_ID!,
  clientSecret: process.env.CLIENT_SECRET!,
  environment: 'sandbox',
});

📚 Code Examples

Check the examples/ folder for complete working examples:

  • basic.ts - Simple ping and list example
  • loda-search.ts - Complete LODA search with all filters
  • juri-search.ts - Complete jurisprudence search examples
  • complete.ts - Combined LODA + JURI example

List LODA Texts

const result = await client.listLoda({
  pageSize: 10,
  pageNumber: 1,
});

console.log(`Total: ${result.totalResultNumber}`);
result.results.forEach(item => {
  console.log(`${item.title} (${item.cid})`);
});

Search with Date Filters

const result = await client.searchLoda('décret', {
  pageSize: 5,
  datePublication: { 
    start: '2025-01-01', 
    end: '2025-12-31' 
  },
});

Search by Nature

import { LodaSearchResult } from 'legifrance-sdk';

const result = await client.searchLoda('travail', {
  natures: [Nature.LOI, Nature.ORDONNANCE],
  pageSize: 10,
});

// Fully typed results!
result.results.forEach((item: LodaSearchResult) => {
  console.log(item.titles[0]?.title);
});

Search Jurisprudence

const result = await client.searchJuri('contrat de travail', {
  pageSize: 10,
  juridictionJudiciaire: ['Cour de cassation'],
  formation: ['Chambre sociale'],
  dateStart: '2024-01-01',
  dateEnd: '2024-12-31',
});

// Fully typed results!
result.results?.forEach((item: JuriSearchResult) => {
  console.log(item.titles?.[0]?.title);
  console.log(`Nature: ${item.nature}`);
});

Consult a Text

const text = await client.consultLoda({
  textId: 'LEGITEXT000006074220',
  date: '2024-01-01',
});

console.log(text.title);

🏗️ Build

npm run build

🧪 Examples

Run examples from the examples/ folder:

# Basic example (ping, list)
npx ts-node examples/basic.ts

# LODA search examples
npx ts-node examples/loda-search.ts

# JURI search examples
npx ts-node examples/juri-search.ts

# Complete example (LODA + JURI)
npx ts-node examples/complete.ts

📄 License

MIT

🤝 Contributing

Made by AI Smarttalk - We build AI-powered solutions.

For issues or feature requests, please open an issue on GitHub.

Updating types

Update swagger files and run the following command

npx swagger-typescript-api generate -p legifrance.swagger.json -o ./src/generated -n api-types.ts --no-client