Skip to main content

Batch-validate and enrich LEI codes via GLEIF API — usable as a library, CLI, or web-app backend

Project description

LEI Enricher

Batch-validate and enrich LEI codes from Excel / CSV files using the GLEIF API, with optional fallback provider.

Built for KYC / AML / compliance teams who maintain spreadsheets with Legal Entity Identifiers.


Features

  • 🔍 GLEIF API — batched lookups (up to 200 LEIs per request), rate-limit friendly
  • 💾 SQLite cache — configurable TTL (default 14 days), avoids redundant API calls
  • 📊 Excel / CSV / ODS input & output
  • 🖥️ Desktop GUI (PySide6) — optional, install with [gui]
  • 🌐 Web-app ready — use enrich_dataframe() directly in Flask / FastAPI / Celery
  • CLIlei-enrich input.xlsx --output enriched.xlsx
  • 🔄 Fallback — optional HTML scrape of lei-lookup.com for GLEIF misses

Installation

Core (no GUI — suitable for servers & web apps)

pip install lei-enricher

With Desktop GUI

pip install "lei-enricher[gui]"

With ODS (LibreOffice Calc) support

pip install "lei-enricher[ods]"

With Flask web backend

pip install "lei-enricher[web]"

Everything

pip install "lei-enricher[all]"

Quickstart

As a Python library

import pandas as pd
from lei_enricher import enrich_dataframe

df = pd.read_excel("my_leis.xlsx")
result = enrich_dataframe(df)
result.to_excel("enriched.xlsx", index=False)

Single LEI lookup

from lei_enricher import GleifClient

client = GleifClient()
results = client.lookup_batch(["HWUPKR0MPOU8FGXBT394", "5493001KJTIIGC8Y1R12"])
for lei, info in results.items():
    print(lei, info.entity_status, info.next_renewal_date)

CLI

lei-enrich input.xlsx --output enriched.xlsx
lei-enrich input.xlsx --lei-col "Company LEI" --sheet "Sheet1" --fallback

Desktop GUI

lei-enricher          # requires: pip install "lei-enricher[gui]"

Flask web app (minimal example)

from flask import Flask, request, send_file
import pandas as pd
from lei_enricher import enrich_dataframe
import io

app = Flask(__name__)

@app.post("/enrich")
def enrich():
    file = request.files["file"]
    df = pd.read_excel(file)
    result = enrich_dataframe(df)
    buf = io.BytesIO()
    result.to_excel(buf, index=False)
    buf.seek(0)
    return send_file(buf, download_name="enriched.xlsx", as_attachment=True)

enrich_dataframe() parameters

Parameter Default Description
df Input DataFrame with LEI column
lei_col auto-detect Column name containing LEI codes
status_col "Entity Status" Output column for entity status
renewal_col "Next Renewal Date" Output column for next renewal date
cache_db ~/lei_cache.sqlite SQLite cache path
cache_days 14 Cache TTL in days
gleif_batch_size 200 LEIs per GLEIF API request
gleif_throttle_s 0.2 Delay (seconds) between GLEIF batches
fallback_enabled False Use lei-lookup.com for GLEIF misses
fallback_throttle_s 1.0 Delay (seconds) between fallback requests
progress_callback None callback(done, total) for progress tracking

Output columns

The enriched file adds two columns immediately to the right of the LEI column:

  • Entity Status — e.g. ACTIVE, LAPSED, MERGED, RETIRED
  • Next Renewal Date — ISO 8601 date string, e.g. 2025-12-31

Project structure

src/lei_enricher/
  __init__.py     — public API
  core.py         — GleifClient, LeiLookupFallback, LeiResult
  cli.py          — enrich_dataframe() + CLI entry point
  cache.py        — SQLite cache
  io_excel.py     — Excel/CSV/ODS read & write
  gui.py          — PySide6 desktop GUI (optional)
  main.py         — GUI entry point (optional)
tests/

License

GPL-3.0-or-later — see LICENSE.

Project details


Download files

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

Source Distribution

lei_enricher-0.1.0.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

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

lei_enricher-0.1.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file lei_enricher-0.1.0.tar.gz.

File metadata

  • Download URL: lei_enricher-0.1.0.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for lei_enricher-0.1.0.tar.gz
Algorithm Hash digest
SHA256 246a680985d71087c2b6a077d711aba02798ca75ee740308c0282bec29dd5e7d
MD5 19a8a05374e610249ec7086b301cb6b1
BLAKE2b-256 ce7306b68ae30175bf6347019f45a550b9e17a989a8b77edf74a0a42f6ed49bc

See more details on using hashes here.

File details

Details for the file lei_enricher-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lei_enricher-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for lei_enricher-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3b7015a3eac3188a6c7951eba0958e84aea92b2a90c8eeda062354ca3ae3a84
MD5 35027cd2d53935d73a680de09424df2e
BLAKE2b-256 16182efca166d89058bc6207fd4bfa20c855bbf710b5b651b3739a61bdb079bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page