Skip to content

bibliofabric.gleif

The GLEIF client (bibliofabric.gleif) reads the Global Legal Entity Identifier Foundation API: LEI records with their entity and registration data, the parent and child relationships around each record, ISIN mappings, field change history, and the code lists (countries, regions, jurisdictions, legal forms, roles, registration authorities, and agents). It can also export a filtered LEI record set as CSV, XLSX, or JSON bytes. Every call returns typed Pydantic models, and an async client ships with a generated sync twin that exposes the same methods.

The upstream references are the GLEIF API page and the live route list.

Credentials

The API needs no credentials. The LEI data and reference data served by the API are published under the CC0 1.0 license (see the GLEIF terms of use). The client paces itself at 0.95 requests per second, inside the documented budget of 60 requests per minute. The Golden Copy and delta files are full downloads, not API routes; the client does not wrap them (see upstream quirks).

Quick start

import asyncio

from bibliofabric.gleif import GleifClient, LeiRecordFilters


async def main() -> None:
    async with GleifClient() as client:
        record = await client.lei_records.get("529900IYQRX2JSSIZA36")
        print(record.lei, "-", record.legal_name, f"({record.country})")

        page = await client.lei_records.search(
            LeiRecordFilters(
                country="DE", registration_status="ISSUED", fulltext="bank"
            ),
            page_size=5,
        )
        print(f"{page.total} German banks match 'bank'")
        for record in page.results:
            print(" ", record.lei, "-", record.legal_name)

        parent = await client.lei_records.ultimate_parent("549300O2RJD085G2U755")
        print("ultimate parent:", parent.lei if parent else None)

        async for record in client.lei_records.iterate(
            LeiRecordFilters(country="LI"), limit=3
        ):
            print("iterated", record.lei)


asyncio.run(main())

The relationship methods answer with the related LEI record (or None when the record has no such parent), and the *_children methods page through every child. isins() returns the ISIN mappings of one record, field_modifications() its change history, newest first.

Sync quick start

GleifSyncClient is generated from the async client and behaves the same: same resources, parameters, errors, and rate limits. It never starts or needs an event loop, so it works in scripts, Jupyter, and threads. See When to use the sync client.

from bibliofabric.gleif import GleifSyncClient

with GleifSyncClient() as client:
    record = client.lei_records.get("529900IYQRX2JSSIZA36")
    print(record.legal_name)

Code lists and completions

import asyncio

from bibliofabric.gleif import CompletionFilters, GleifClient, LeiRecordFilters


async def main() -> None:
    async with GleifClient() as client:
        page = await client.entity_legal_forms.search(page_size=200)
        print(f"{page.total} legal forms")

        hits = await client.autocompletions.search(
            CompletionFilters(field="fulltext"), query="bank"
        )
        for hit in hits.results:
            print(hit.value)

        csv_bytes = await client.export_lei_records(
            "csv", LeiRecordFilters(country="LI")
        )
        print(len(csv_bytes), "bytes of CSV")


asyncio.run(main())

The registry resources (fields, countries, regions, jurisdictions, entity_legal_forms, official_organizational_roles, registration_authorities, registration_agents, lei_issuers, vlei_issuers) all support get, search, iterate, collect, first, and count. lei_issuers.jurisdictions(id) lists the jurisdictions one LEI issuer covers.

Where to go next