# GLEIF Entity Resolver (`your_friendly_developer/gleif-entity-resolver`) Actor

Resolves legal company names or LEI codes to GLEIF records in bulk: LEI, legal name, legal form, registered address, entity status and registration status, with punctuation-tolerant name matching.

- **URL**: https://apify.com/your_friendly_developer/gleif-entity-resolver.md
- **Developed by:** [Jason Ramirez](https://apify.com/your_friendly_developer) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $50.00 / 1,000 entity resolveds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## GLEIF Company Entity Resolver

An Apify Actor for compliance, KYC, and finance-data teams resolving counterparties in bulk. It accepts legal names or LEI codes and writes one dataset item per input. It uses the public GLEIF API at `https://api.gleif.org/api/v1`, with no API key configured.

API endpoint behavior and payload shapes are based on BRIEF.md and synthetic fixtures. Live API compatibility has not been verified in this build.

### Input

```json
{
  "companies": [
    { "value": "Example Holdings Ltd", "country": "GB" },
    { "value": "529900T8BM49AURSDO55" }
  ],
  "includeCandidates": true
}
```

The examples are illustrative, not verified entity identities. Supply 1 to 500 company objects. Country is optional and must be a two-letter code; it filters name searches only. Names are trimmed and repeated whitespace is collapsed. LEI detection checks 20-character ISO 17442 format, including two trailing numeric check digits; it does not validate the checksum. Lowercase LEI input is normalized to uppercase. `includeCandidates` defaults to true. Invalid company entries yield individual error items; an invalid top-level input stops the run before requests.

### Matching rules

- `exact`: a direct LEI lookup returned an identifiable record, or one legal name matched case-insensitively after whitespace normalization. Exact name equality does not establish that this is the intended counterparty.
- `top-candidate`: a name search returned only one identifiable, nonexact candidate. This is a suggestion, never a certain match.
- `ambiguous`: more than one exact name, or more than one nonexact candidate in the returned page. All multiple nonexact results are conservatively considered close enough to require review. No primary entity is selected; entity fields are null or empty. Candidates remain in API order, with exact names promoted first, up to five. Setting `includeCandidates` false hides the list but preserves ambiguity.
- `not-found`: no identifiable result, including a direct LEI lookup returning HTTP 404. API and input failures also use this matchType with an `error` field; consumers must inspect `error` before interpreting an item as a clean miss.

Search requests ask for five results. Ranking prefers exact legal names and otherwise preserves GLEIF ordering. It performs no additional fuzzy scoring or pagination. Ambiguous and clean not-found outcomes are normal outputs, not errors.

### Output

| Field | Shape and meaning |
| --- | --- |
| input | Original company object |
| inputType | `lei` or `name`; null if input normalization failed |
| matchType | `exact`, `top-candidate`, `ambiguous`, or `not-found` |
| lei | Selected record identifier or null |
| legalName | Legal name or null |
| otherNames | Up to three alternative name strings; empty when absent |
| legalForm | Legal form identifier, falling back to free text; null if absent |
| registeredAt | `{ locality, country }` from legal address, each nullable |
| entityStatus | Entity status or null |
| registrationStatus | LEI registration status or null |
| registrationAuthority | Entity registered-at authority identifier or null |
| initialRegistrationDate | Registration timestamp string or null |
| lastUpdateDate | Update timestamp string or null |
| nextRenewalDate | Renewal timestamp string or null |
| managingLou | Managing LOU identifier or null |
| candidates | Only for ambiguous outcomes when enabled: up to five `{ lei, legalName, country }` objects |
| resolvedAt | Processing timestamp in ISO format, including misses and failures |
| error | Present on individual failures; message string |

Missing scalar fields become null. Missing alternative names become an empty array. Results are written sequentially. Individual HTTP, fetch, JSON, and company-validation failures are isolated. Dataset or key-value storage failures stop the run rather than silently losing results.

`LAST_RUN_SUMMARY` stores `{ runAt, inputsRequested, resolved, ambiguous, notFound, failed }`. Counts are mutually exclusive: resolved includes exact and top-candidate items; failed includes error items and excludes them from notFound. `runAt` is the start timestamp. The summary is written after all dataset writes complete.

### Limits

GLEIF covers LEI-registered entities only. According to the supplied product brief, a not-found usually means the company has no LEI; this is an asserted coverage expectation, not a verified diagnosis of any company. Spelling, filters, and returned-page coverage can also affect results. Review suggested and ambiguous matches before using them.

Requests run one at a time with a 250 ms delay before each request and a 30-second fetch timeout. There are no automatic retries. At most 500 inputs are accepted. The small delay is a local reasonable-use choice, not a verified GLEIF rate allowance.

### Local run

Use Node.js 22, as selected in the Dockerfile. In an environment where dependency installation and network access are permitted:

```sh
npm install
mkdir -p storage/key_value_stores/default
```

Save the input JSON to `storage/key_value_stores/default/INPUT.json`, then run:

```sh
npm start
```

The entrypoint uses Apify SDK v3 lifecycle, dataset, and key-value store APIs. SDK installation, local storage behavior, container build, and live API calls have not been exercised here. The previous unrelated root package lock was removed because it described the prior application; generate a new lock after an authorized dependency installation.

Run fixture-based checks with no dependency installation or network calls:

```sh
npm test
```

The suite uses Node's built-in test runner and injected fetch/delay functions. `test/fixtures/gleif.json` contains ASSERTED synthetic payloads, including single, exact search, near search, empty, and API error cases.

### Publication gate

This build does not configure billing, publish, deploy, or charge events. Pay-per-event charging per resolved input is a publication-time requirement in BRIEF.md. The owner must confirm current platform billing mechanics and configure that requirement before publication; no pricing is asserted here.

# Actor input Schema

## `companies` (type: `array`):

One to 500 legal names or LEI codes, optionally restricted by country.

## `includeCandidates` (type: `boolean`):

When a name matches several entities, include the candidate list on the result row.

## Actor input object example

```json
{
  "companies": [
    {
      "value": "Apple Inc",
      "country": "US"
    }
  ],
  "includeCandidates": true
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing one resolution row per input company

## `keyValueStore` (type: `string`):

Default key-value store holding the LAST_RUN_SUMMARY record

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "companies": [
        {
            "value": "Apple Inc",
            "country": "US"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("your_friendly_developer/gleif-entity-resolver").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "companies": [{
            "value": "Apple Inc",
            "country": "US",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("your_friendly_developer/gleif-entity-resolver").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "companies": [
    {
      "value": "Apple Inc",
      "country": "US"
    }
  ]
}' |
apify call your_friendly_developer/gleif-entity-resolver --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,your_friendly_developer/gleif-entity-resolver"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/fZeIrwOIZob65FHIr/builds/CCxAbf7diacqeOrFp/openapi.json
