---
title: "Authentication"
summary: "When using the hosted OpenSanctions API, you must always provide an API key when you make requests."
url: "https://www.opensanctions.org/docs/api/authentication/"
date_updated: "2026-07-17"
---

{% alert variant="info" %}
You need authentication to use the [hosted API](/api/).
See the [yente documentation](https://yente.followthemoney.tech/delivery/) if you are running it [on-premise](/docs/on-premise/).
{% /alert %}

To use the OpenSanctions API, you need an API key to identify yourself. Please visit the [API product page](/api/) or [contact us](/contact/) to learn more.

We issue [free API keys for public-interest work](/docs/commercial/exemption/): journalism, civil-society advocacy, and academic research.

Once you have obtained an [API key](/account/), you must include it with each request sent to the service. The key must be provided in the `Authorization` HTTP header:

```
Authorization: ApiKey xxxxxxxxxxxxxxxxxxxxxxxx
```

{% alert variant="warning" %}
Your API key should be kept secret — keep it safe to prevent unauthorized use of your OpenSanctions account.
{% /alert %}

### Python example

Here's a code snippet that demonstrates how you can include the API key in each request when using the Python `requests` library:

```bash
export OPENSANCTIONS_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxx" # replace with your own
python ↓
```

```python
import os
import requests

API_URL = "https://api.opensanctions.org"
# Read an environment variable to get the API key:
API_KEY = os.environ.get("OPENSANCTIONS_API_KEY")

session = requests.Session()
session.headers['Authorization'] = f"ApiKey {API_KEY}"

# Run a match query:
query = {"schema": "Person", "properties": {"name": ["Vladimir Putin"]}}
request = {"queries": {"query": query}}
response = session.post(f"{API_URL}/match/default", json=request)
response.raise_for_status()
results = response.json().get("responses").get("query").get("results")

# Fetch an entity:
response = session.get(f"{API_URL}/entities/Q7747")
response.raise_for_status()
entity_data = response.json()
```
