Source: https://eventregistry.org/documentation?tab=ner

# Named entity recognition

Detect the people, organizations, locations, dates and other named entities mentioned in the provided document.

The API call can be used to extract the named entities mentioned in the provided document. The identified entities include people, organizations, locations, dates, currencies and similar. For each entity we return the mentioned text, the character offsets of the mention in the document and the entity type. Compared to the `annotate` endpoint, the named entity recognition does not disambiguate the entities to their corresponding Wikipedia pages — it only identifies which parts of the text represent named entities and of which type. On the other hand, it can also identify entities that don't have their own Wikipedia page, such as dates, monetary amounts or less known people and organizations. The named entity recognition is supported for documents in English, German, Spanish and Chinese language.

**Endpoint:** GET | POST `http://analytics.eventregistry.org/api/v1/ner`

**Headers:** Content-Type: application/json

#### `Parameters`

#### `apiKey`

string (required)

Your API key

#### `text`

string (required)

Define a text in which you'll like to detect the named entities.

## Request examples

### Example 1

Request body:

```json
{
  "text": "Microsoft chief executive Satya Nadella visited Berlin on May 5th, 2024.",
  "apiKey": "YOUR_API_KEY"
}
```

```python
from eventregistry import *
er = EventRegistry(apiKey = YOUR_API_KEY)
analytics = Analytics(er)

nerInfo = analytics.ner("Microsoft chief executive Satya Nadella visited Berlin on May 5th, 2024.")

for entity in nerInfo.get("entities", []):
    print(entity)
```

```javascript
var er = new erBase.EventRegistry();
                    var analytics = new erBase.Analytics(er);
                    analytics.ner("Microsoft chief executive Satya Nadella visited Berlin on May 5th, 2024.").then((nerInfo) => {
                        console.log(nerInfo);
                    });
```

```typescript
const er = new EventRegistry();
                    const analytics = new Analytics(er);
                    analytics.ner("Microsoft chief executive Satya Nadella visited Berlin on May 5th, 2024.").then((nerInfo) => {
                        console.log(nerInfo);
                    });
```

## Example output

```json
{
  "entities": [
    {
      "startCh": 0,
      "endCh": 9,
      "type": "ORGANIZATION",
      "text": "Microsoft"
    },
    {
      "startCh": 10,
      "endCh": 25,
      "type": "TITLE",
      "text": "chief executive"
    },
    {
      "startCh": 26,
      "endCh": 39,
      "type": "PERSON",
      "text": "Satya Nadella"
    },
    {
      "startCh": 48,
      "endCh": 54,
      "type": "CITY",
      "text": "Berlin"
    },
    {
      "startCh": 58,
      "endCh": 71,
      "type": "DATE",
      "text": "May 5th, 2024"
    },
    {
      "startCh": 85,
      "endCh": 91,
      "type": "NATIONALITY",
      "text": "German"
    },
    {
      "startCh": 115,
      "endCh": 127,
      "type": "MONEY",
      "text": "$3.4 billion"
    }
  ]
}
```

## Output schema

```json
{
  "type": "object",
  "properties": {
    "entities": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "example": "Microsoft"
          },
          "startCh": {
            "type": "integer",
            "example": 0
          },
          "endCh": {
            "type": "integer",
            "example": 9
          },
          "type": {
            "type": "string",
            "example": "ORGANIZATION"
          }
        }
      }
    }
  }
}
```
