The GLEIF LEI API (https://api.gleif.org/api/v1, JSON:API, no
key): LEI records by full-text or filtered search, fuzzy and
autocomplete name suggestions, records by LEI or ISIN, ISINs per
LEI, and the Level 2 relationship data (direct and ultimate parents,
their relationship records and reporting exceptions, and children).
Lists are page-number paginated (page[size] up to 200,
page[number] from 1); next-page reads the next page number from
meta.pagination, and collect follows it. GLEIF asks clients to
stay under 60 requests per minute.
Every function takes an optional trailing opts Map: page-size,
page, filters (extra filter[...] parameters, e.g.
{"entity.legalAddress.country": "US", "entity.status": "ACTIVE"}),
and base-url.
Context Vars
gleif.base-url
Values
ACCEPT
ACCEPT: Str "application/vnd.api+json"
LETTER_VALUES
LETTER_VALUES: Map {
A: 10,
B: 11,
C: 12,
D: 13,
E: 14,
F: 15,
G: 16,
H: 17,
I: 18,
J: 19,
K: 20,
L: 21,
M: 22,
N: 23,
O: 24,
P: 25,
Q: 26,
R: 27,
S: 28,
T: 29,
U: 30,
V: 31,
W: 32,
X: 33,
Y: 34,
Z: 35
}
MAX_PAGE_SIZE
MAX_PAGE_SIZE: Int 200
Functions
autocompletions
fn (q: Str): Vec<Map>
fn (q: Str, opts: Map): Vec<Map>
Prefix suggestions (/autocompletions, opts.field default
"fulltext"). Returns [{name, lei}].
Example
suggestions ::gleif/autocompletions("apple")
map(suggestions, %.name)
by-isin
fn (isin: Str): Vec<Map>
fn (isin: Str, opts: Map): Vec<Map>
The LEI records issuing an ISIN (filter[isin]).
Example
issuers ::gleif/by-isin("US0378331005")
map(issuers, %.attributes.entity.legalName.name)
collect
fn (fetch: Fn, opts: Map, limit: Int): Vec
Follow pages of a paginated GLEIF call until limit items or the
last page. fetch takes opts (with page and page-size set)
and returns one page. An Err on any page is returned in place of the
items.
Example
::gleif ::gleif
kids ::gleif/collect((o) { ::gleif/direct-children("HWUPKR0MPOU8FGXBT394", o) }, {}, 500)
completions
fn (body: Any): Vec<Map>
[{name, lei}] from a fuzzy or auto completion response (pure).
Example
body {data: [{
attributes: {value: "Apple Inc."},
relationships: {"lei-records": {data: {id: "HWUPKR0MPOU8FGXBT394"}}}
}]}
::gleif/completions(body) // [{name: "Apple Inc.", lei: "HWUPKR0MPOU8FGXBT394"}]
::gleif/completions(null) // []
direct-children
fn (lei: Str): Map
fn (lei: Str, opts: Map): Map
One page of the entities directly consolidated by lei (LEI records).
Example
page ::gleif/direct-children("HWUPKR0MPOU8FGXBT394", {page-size: 50})
map(page.data, %.attributes.entity.legalName.name)
::gleif/next-page(page)
direct-parent
fn (lei: Str): Map?
fn (lei: Str, opts: Map): Map?
The direct accounting-consolidation parent's LEI record, or null when
none is reported (check direct-parent-exception for the reason).
Example
parent ::gleif/direct-parent("549300G81RQKP7XW2N18")
if(is-some(parent), parent.attributes.entity.legalName.name, "None reported")
direct-parent-exception
fn (lei: Str): Map?
fn (lei: Str, opts: Map): Map?
Why no direct parent is reported (attributes.reason, e.g.
NATURAL_PERSONS, NON_CONSOLIDATING), or null.
Example
why ::gleif/direct-parent-exception("HWUPKR0MPOU8FGXBT394")
if(is-some(why), why.attributes.reason, "A parent is reported")
direct-parent-relationship
fn (lei: Str): Map?
fn (lei: Str, opts: Map): Map?
The direct-parent relationship record (IS_DIRECTLY_CONSOLIDATED_BY,
with periods and validation), or null.
Example
record ::gleif/direct-parent-relationship("549300G81RQKP7XW2N18")
if(is-some(record), record.attributes.relationship.endNode.id, null)
filter-params
fn (filters: Map?): Map
filter[<field>] parameters from a Map of field → value (pure):
{"entity.status": "ACTIVE"} → {"filter[entity.status]": "ACTIVE"}.
Example
::gleif/filter-params({"entity.status": "ACTIVE"}) // {"filter[entity.status]": "ACTIVE"}
::gleif/filter-params(null) // {}
fuzzy-completions
fn (q: Str): Vec<Map>
fn (q: Str, opts: Map): Vec<Map>
Fuzzy name suggestions (/fuzzycompletions), which tolerate
misspellings. opts.field defaults to "entity.legalName"
("fulltext" and "owns"/"ownedBy" also work). Returns
[{name, lei}].
Example
::gleif/fuzzy-completions("appel inc") // [{name: "Apple Inc.", lei: "HWUPKR0MPOU8FGXBT394"}, ...]
get-record
fn (lei: Str): Map?
fn (lei: Str, opts: Map): Map?
One LEI record by LEI (the JSON:API data object), or null when GLEIF
has none.
Example
record ::gleif/get-record("HWUPKR0MPOU8FGXBT394")
if(is-some(record), record.attributes.entity.legalName.name, "No such LEI")
is-lei
fn (lei: Str): Bool
True for a syntactically valid LEI: 20 characters, 18 alphanumerics and two check digits, with a valid ISO 17442 (MOD 97-10) checksum.
Example
::gleif/is-lei("HWUPKR0MPOU8FGXBT394") // true
::gleif/is-lei("HWUPKR0MPOU8FGXBT395") // false
::gleif/is-lei("APPLE") // false
isins
fn (lei: Str): Map
fn (lei: Str, opts: Map): Map
One page of the ISINs mapped to an LEI (GLEIF's daily ISIN-to-LEI file,
via the API). Returns the page; data[].attributes.isin holds each
ISIN.
Example
page ::gleif/isins("HWUPKR0MPOU8FGXBT394", {page-size: 50})
map(page.data, %.attributes.isin)
page.meta.pagination.total
lei-path
fn (lei: Str): Str
/lei-records/{lei} with the LEI upper-cased and encoded (pure).
Example
::gleif/lei-path(" hwupkr0mpou8fgxbt394 ") // "/lei-records/HWUPKR0MPOU8FGXBT394"
next-page
fn (page: Any): Int?
The page number after page from meta.pagination (currentPage <
lastPage), or null on the last page (pure).
Example
::gleif/next-page({meta: {pagination: {currentPage: 1, lastPage: 32}}}) // 2
::gleif/next-page({meta: {pagination: {currentPage: 32, lastPage: 32}}}) // null
page-params
fn (opts: Map): Map
page[size] and page[number] from opts.page-size (capped at 200)
and opts.page (pure). An unset value is null, and
::gleif::api/query-string drops it.
Example
::gleif/page-params({page-size: 500, page: 3}) // {"page[size]": 200, "page[number]": 3}
search
fn (name: Str): Map
fn (name: Str, opts: Map): Map
Full-text search of LEI records (filter[fulltext]: legal and other
names, and more). Returns the JSON:API page: data (records),
meta.pagination and links.
Example
page ::gleif/search("apple inc", {page-size: 10, filters: {"entity.legalAddress.country": "US"}})
first(page.data).attributes.entity.legalName.name
search-legal-name
fn (name: Str): Map
fn (name: Str, opts: Map): Map
Search by legal name only (filter[entity.legalName]), which is
stricter than full text.
Example
page ::gleif/search-legal-name("Apple Inc.", {page-size: 5})
map(page.data, %.attributes.entity.legalName.name)
// Active US entities only
us ::gleif/search-legal-name("Apple Inc.", {filters: {
"entity.legalAddress.country": "US",
"entity.status": "ACTIVE"
}})
us.meta.pagination.total
search-params
fn (name: Str, opts: Map): Map
Query parameters for a full-text LEI search (pure): filter[fulltext],
the extra filters, and paging.
Example
::gleif/search-params("apple inc", {page-size: 10, page: 2})
// {"filter[fulltext]": "apple inc", "page[size]": 10, "page[number]": 2}
ultimate-children
fn (lei: Str): Map
fn (lei: Str, opts: Map): Map
One page of the entities ultimately consolidated by lei (LEI records).
Example
page ::gleif/ultimate-children("HWUPKR0MPOU8FGXBT394", {page-size: 50, page: 2})
map(page.data, %.id)
ultimate-parent
fn (lei: Str): Map?
fn (lei: Str, opts: Map): Map?
The ultimate accounting-consolidation parent's LEI record, or null when none is reported.
Example
parent ::gleif/ultimate-parent("549300G81RQKP7XW2N18")
if(is-some(parent), parent.id, "None reported")
ultimate-parent-exception
fn (lei: Str): Map?
fn (lei: Str, opts: Map): Map?
Why no ultimate parent is reported, or null.
Example
why ::gleif/ultimate-parent-exception("HWUPKR0MPOU8FGXBT394")
if(is-some(why), why.attributes.reason, "A parent is reported")
ultimate-parent-relationship
fn (lei: Str): Map?
fn (lei: Str, opts: Map): Map?
The ultimate-parent relationship record
(IS_ULTIMATELY_CONSOLIDATED_BY), or null.
Example
record ::gleif/ultimate-parent-relationship("549300G81RQKP7XW2N18")
if(is-some(record), record.attributes.relationship.status, null)