Skip to main content

Rechtspraak extractor

This library contains two functions to get rechtspraak data and metadata from the API.

Version

Python 3.9+

Contributors

pranavnbapat
Pranav Bapat
running-machin
running-machin
Cloud956
Piotr Lewandowski
shashankmc
shashankmc
gijsvd
gijsvd
sha-sub
Shashank Subramanya

How to install?

pip install rechtspraak_extractor

What are the functions?

  • Rechtspraak Extractor
    1. get_rechtspraak
    2. Gets all the ECLIs and saves them in the CSV file or in-memory.
      It gets, ECLI, title, summary, updated date, link.
    3. get_rechtspraak_metadata
    4. Gets the metadata of the ECLIs created by above function and saves them in the new CSV file or in-memory.
      Link attribute that we get from the above function contains the links of ECLI metadata.
      It gets instantie, datum uitspraak, datum publicatie, zaaknummer, rechtsgebieden, bijzondere kenmerken, inhoudsindicatie, and vindplaatsen.
      Supports two extraction methods: method='api' (default, fetches live from Rechtspraak API) and method='sqlite' (fetches from a local pre-built SQLite database — see below).
      The method='api' supports case text (uitspraak) extraction split by sections or as a single block.
    5. fetch_eclis_via_sqlite
    6. Low-level function to look up a list of ECLIs directly from a local SQLite database and return a DataFrame. Requires the rechtspraak-lido-sqlite package to be installed and its database populated first (see SQLite method below).
  • What are the parameters?

    1. get_rechtspraak(max_ecli=100, sd='2022-05-01', ed='2022-10-01', save_file='y')
    2. Parameters:
      • max_ecli: int, optional
      • Maximum amount of ECLIs to retrieve
        Default: 100
      • sd: date, optional, default '2022-08-01'
      • The start publication date (yyyy-mm-dd)
      • ed: date, optional, default current date
      • The end publication date (yyyy-mm-dd)
      • save_file: ['y', 'n'], default 'y'
      • y - Save data as a CSV file in data folder
        n - Save data as a dataframe in-memory
    3. get_rechtspraak_metadata(...)
      • save_file: ['y', 'n'], default 'n'
      • y - Save data as a CSV file in data folder
        n - Return data as a dataframe in-memory
      • dataframe: dataframe, optional
      • Dataframe containing ECLIs to retrieve metadata. Cannot be combined with filename
      • filename: string, optional
      • CSV file containing ECLIs to retrieve metadata. Cannot be combined with dataframe
      • method: ['api', 'sqlite'], default 'api'
      • api - Fetch metadata live from the Rechtspraak API
        sqlite - Fetch metadata from a local SQLite database (requires rechtspraak-lido-sqlite)
      • sqlite_db_path: string, default 'data/lido_metadata.db'
      • Path to the SQLite database file. Only used when method='sqlite'
      • fallback_to_api: bool, default True
      • When using method='sqlite', fall back to the live API for any ECLIs not found in the database
      • multi_threading: bool, default True
      • Use multi-threading for API-based metadata extraction. Set to False for single-threaded execution
      • extract_text_by_sections: ['y', 'n'], default 'n'
      • y - Extract case text (uitspraak) split by sections. Applicable only for method='api'
        n - Extract case text as a single block.
    4. fetch_eclis_via_sqlite(ecli_list, sqlite_db_path, columns)
      • ecli_list: list[str]
      • List of ECLI identifiers to look up
      • sqlite_db_path: string
      • Path to the SQLite database file produced by rechtspraak-lido-sqlite
      • columns: list[str]
      • Column names to select from the database

    Examples

    Downloading ECLIs

    import rechtspraak_extractor as rex
    
    # Get rechtspraak data as a DataFrame (100 ECLIs since 2022-08-01)
    df = rex.get_rechtspraak(max_ecli=100, sd="2022-08-01", save_file="n")
    
    # Save rechtspraak data directly to CSV in the data/ folder
    rex.get_rechtspraak(max_ecli=100, sd="2022-08-01", save_file="y")
    

    Extracting metadata via the live API (default)

    # Get metadata into a DataFrame from an existing DataFrame
    df_metadata = rex.get_rechtspraak_metadata(save_file="n", dataframe=df)
    
    # Get metadata into a DataFrame from a CSV produced by get_rechtspraak
    df_metadata = rex.get_rechtspraak_metadata(save_file="n", filename="rechtspraak.csv")
    
    # Produce metadata CSV from an in-memory DataFrame
    rex.get_rechtspraak_metadata(save_file="y", dataframe=df)
    
    # Produce metadata CSV from files already in data/ (processes all files)
    rex.get_rechtspraak_metadata(save_file="y")
    
    # Get metadata into a DataFrame from an existing DataFrame with case text split by sections
    df_metadata = rex.get_rechtspraak_metadata(save_file="n", dataframe=df, extract_text_by_sections="y")
    
    • filename refers to a file in the data/ folder created by get_rechtspraak.
    • df is the DataFrame returned by get_rechtspraak.

    Extracting metadata via SQLite (offline, faster)

    The SQLite method fetches metadata from a local pre-built database instead of making live API calls. This is significantly faster for large batches and works offline.

    Prerequisite: The rechtspraak-lido-sqlite package must be installed and its database must be built locally before using this method.

    pip install rechtspraak-lido-sqlite
    

    After installing, follow the rechtspraak-lido-sqlite instructions to build the local database (typically produces a file at data/lido.db or a path you configure).

    Using get_rechtspraak_metadata with method='sqlite'

    import rechtspraak_extractor as rex
    
    df = rex.get_rechtspraak(max_ecli=500, sd="2025-01-01", save_file="n")
    
    # Fetch metadata from local SQLite database
    df_metadata = rex.get_rechtspraak_metadata(
        save_file="n",
        dataframe=df,
        method="sqlite",
        sqlite_db_path="data/lido.db",   # path to the database built by rechtspraak-lido-sqlite
        fallback_to_api=True,            # fall back to live API for ECLIs not found in the DB
    )
    

    Using fetch_eclis_via_sqlite directly

    from rechtspraak_extractor.rechtspraak_metadata import fetch_eclis_via_sqlite
    
    eclis = ["ECLI:NL:HR:2023:1", "ECLI:NL:HR:2023:2"]
    
    columns = ["ecli", "document_type", "date_decision", "instance", "full_text"]
    
    df = fetch_eclis_via_sqlite(
        ecli_list=eclis,
        sqlite_db_path="data/lido.db",
        columns=columns,
    )
    

    Note: If the database file does not exist or an ECLI is not found in it, fetch_eclis_via_sqlite returns an empty DataFrame rather than raising an error. Use fallback_to_api=True in get_rechtspraak_metadata to automatically cover missing ECLIs via the live API.

    License

    License: Apache 2.0

    Previously under the MIT License, as of 28/10/2022 this work is licensed under a Apache License, Version 2.0.

    Apache License, Version 2.0
    
    Copyright (c) 2022 Maastricht Law & Tech Lab
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
        
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    

    Download files

    Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

    Source Distribution

    rechtspraak_extractor-1.7.3.tar.gz (51.5 kB view details)

    Uploaded Source

    Built Distribution

    If you're not sure about the file name format, learn more about wheel file names.

    rechtspraak_extractor-1.7.3-py3-none-any.whl (33.9 kB view details)

    Uploaded Python 3

    File details

    Details for the file rechtspraak_extractor-1.7.3.tar.gz.

    File metadata

    • Download URL: rechtspraak_extractor-1.7.3.tar.gz
    • Upload date:
    • Size: 51.5 kB
    • Tags: Source
    • Uploaded using Trusted Publishing? Yes
    • Uploaded via: twine/7.0.0 CPython/3.13.14

    File hashes

    Hashes for rechtspraak_extractor-1.7.3.tar.gz
    Algorithm Hash digest
    SHA256 baa1c97efbcc11fd17ceab4cec4dd59ad02d43367201cbc969ee8942233ed0e8
    MD5 63bf1b1702a30e0afd7a18bbc7191a89
    BLAKE2b-256 1c762f0d5f0c84220939aa7c754c1c7b78fa399143bd6232fab981bc076e8b92

    See more details on using hashes here.

    Provenance

    The following attestation bundles were made for rechtspraak_extractor-1.7.3.tar.gz:

    Publisher: github-actions.yml on maastrichtlawtech/rechtspraak-extractor

    Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

    File details

    Details for the file rechtspraak_extractor-1.7.3-py3-none-any.whl.

    File metadata

    File hashes

    Hashes for rechtspraak_extractor-1.7.3-py3-none-any.whl
    Algorithm Hash digest
    SHA256 c2526648cae7a3a3575f74dfc9ba5e3fdcd70a27632486581c79e12b3764efb9
    MD5 ca883cc73d6b61332a05605fc3b545bb
    BLAKE2b-256 29f228c553712e1c15a7644009b867fa0d9cb2f7a2069cee941afd41ac3124cf

    See more details on using hashes here.

    Provenance

    The following attestation bundles were made for rechtspraak_extractor-1.7.3-py3-none-any.whl:

    Publisher: github-actions.yml on maastrichtlawtech/rechtspraak-extractor

    Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

    Release history Release notifications | RSS feed

    This release

    1.7.3 This release

    2 files

    1.7.2

    2 files

    1.7.1

    2 files

    1.7.0

    2 files

    1.6.0

    2 files

    1.5.4

    2 files

    1.5.3

    2 files

    1.5.2

    2 files

    1.5.1

    2 files

    1.5.0

    2 files

    1.4.2

    2 files

    1.4.1

    2 files

    1.3.0

    2 files

    1.2.3

    2 files

    1.2.2

    2 files

    1.2.1

    2 files

    1.1.21

    1 file

    1.1.20

    1 file

    1.1.19

    1 file

    1.1.18

    1 file

    1.1.17

    1 file

    1.1.16

    1 file

    1.1.15

    1 file

    1.1.14

    1 file

    1.1.13

    1 file

    1.1.12

    1 file

    1.1.11

    1 file

    1.1.10

    1 file

    1.1.9

    1 file

    1.1.8

    1 file

    1.1.7

    1 file

    1.1.6

    1 file

    1.1.5

    1 file

    1.1.4

    1 file

    1.1.3

    1 file

    1.1.2

    2 files

    1.1.1

    1 file

    1.1

    2 files

    1.0.43

    1 file

    1.0.42

    1 file

    1.0.41

    1 file

    1.0.40

    1 file

    1.0.39

    1 file

    1.0.38

    1 file

    1.0.37

    1 file

    1.0.36

    1 file

    1.0.35

    1 file

    1.0.34

    1 file

    1.0.33

    1 file

    1.0.32

    1 file

    1.0.31

    1 file

    1.0.30

    1 file

    1.0.29

    1 file

    1.0.28

    1 file

    1.0.27

    1 file

    1.0.26

    1 file

    1.0.25

    1 file

    1.0.24

    1 file

    1.0.23

    1 file

    1.0.22

    1 file

    1.0.21

    1 file

    1.0.20

    1 file

    1.0.19

    1 file

    1.0.18

    1 file

    1.0.17

    1 file

    1.0.16

    1 file

    1.0.15

    1 file

    1.0.14

    1 file

    1.0.13

    1 file

    1.0.12

    1 file

    1.0.11

    1 file

    1.0.10

    1 file

    1.0.9

    1 file

    1.0.8

    1 file

    1.0.7

    1 file

    1.0.6

    1 file

    1.0.5

    1 file

    1.0.4

    1 file

    1.0.3

    1 file

    1.0.1

    2 files

    1.0

    1 file

    Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page