I want to retrieve data from OpenSanctions Database using Python, but I'm not sure how to
use their API.
I have already created an
API key: e8e46841798b13ecb2a416cfcd98e3f0
My goal is to fetch 100 entities from the "People" dataset. I tried accessing the API using the documentation at OpenSanctions Default Dataset, but
I received a 404 error with no details found.
Can you show me the correct way to use the API in Python to get this data?
import requests
# Define your API key and the endpoint
api_key = 'e8e46841798b13ecb2a416cfcd98e3f0'
url = ''  # Corrected search endpoint
# Set the headers with the API key
headers = {
    'Authorization': f'Bearer {api_key}',
}
# Define the parameters for your search request
params = {
    'schema': 'Person',  # Use 'schema' instead of 'entity_type'
    'limit': 100,  # Limit to 100 records
    'q': ''  # Optionally add a search query, e.g., 'q': 'John Doe'
}
# Make the GET request to the API
response = requests.get(url, headers=headers, params=params)
# Check if the request was successful
if response.status_code == 200:
    data = response.json()
    # Print the returned data
    print(data)
else:
    print(f"Error: {response.status_code} - {response.text}")