When using the hosted OpenSanctions API, you must always provide an API key when you make requests.
When using the hosted OpenSanctions API, you must always provide an API key when you make requests.
You need authentication to use the hosted API. See the yente documentation if you are running it on-premise.
To use the OpenSanctions API, you need an API key to identify yourself. Please visit the API product page or contact us to learn more.
We issue free API keys to journalists, anti-corruption activists and academic research projects related to sanctions policy.
Once you have obtained an API key, you must include it with each request sent to the service. The key must be provided in the Authorization HTTP header:
Authorization: ApiKey xxxxxxxxxxxxxxxxxxxxxxxx
Your API key should be kept secret — keep it safe to prevent unauthorized use of your OpenSanctions account.
Here's a code snippet that demonstrates how you can include the API key in each request when using the Python requests library:
export OPENSANCTIONS_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxx" # replace with your own
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()