SDK Examples
Code examples for integrating SanctionsWise API in various languages.
Python​
Basic Client​
import requests
import os
class SanctionsWiseClient:
"""SanctionsWise API Python Client."""
def __init__(self, api_key=None):
self.api_key = api_key or os.environ.get("SANCTIONSWISE_API_KEY")
if not self.api_key:
raise ValueError("API key required")
self.base_url = "https://api.orchestraprime.ai/sanctionswise"
self.session = requests.Session()
self.session.headers.update({
"x-api-key": self.api_key,
"Content-Type": "application/json"
})
def screen_entity(self, name, entity_type="individual", threshold=0.85,
lists=None, identifiers=None):
"""Screen a single entity."""
payload = {
"name": name,
"entity_type": entity_type,
"threshold": threshold
}
if lists:
payload["lists"] = lists
if identifiers:
payload["identifiers"] = identifiers
response = self.session.post(
f"{self.base_url}/screen/entity",
json=payload,
timeout=30
)
response.raise_for_status()
return response.json()
def screen_batch(self, entities, threshold=0.85, lists=None,
max_results_per_entity=5):
"""Screen multiple entities."""
payload = {
"entities": entities,
"options": {
"threshold": threshold,
"max_results_per_entity": max_results_per_entity
}
}
if lists:
payload["options"]["lists"] = lists
response = self.session.post(
f"{self.base_url}/screen/batch",
json=payload,
timeout=120
)
response.raise_for_status()
return response.json()
def get_entity(self, entity_id):
"""Get entity details."""
response = self.session.get(
f"{self.base_url}/entities/{entity_id}",
timeout=30
)
response.raise_for_status()
return response.json()
def get_lists(self):
"""Get available sanctions lists."""
response = self.session.get(
f"{self.base_url}/lists",
timeout=30
)
response.raise_for_status()
return response.json()
# Usage
client = SanctionsWiseClient()
# Screen individual
result = client.screen_entity("Vladimir Putin", threshold=0.60)
print(f"Status: {result['status']}, Matches: {result['match_count']}")
# Screen with identifiers
result = client.screen_entity(
"John Doe",
identifiers={"passport": "AB1234567", "date_of_birth": "1965-03-15"}
)
# Batch screening
entities = [
{"name": "John Smith", "entity_type": "individual"},
{"name": "Acme Corp", "entity_type": "organization"}
]
batch_result = client.screen_batch(entities)
print(f"Clear: {batch_result['summary']['clear']}, Flagged: {batch_result['summary']['potential_matches']}")
JavaScript / Node.js​
Basic Client​
const axios = require('axios');
class SanctionsWiseClient {
constructor(apiKey) {
this.apiKey = apiKey || process.env.SANCTIONSWISE_API_KEY;
if (!this.apiKey) {
throw new Error('API key required');
}
this.baseUrl = 'https://api.orchestraprime.ai/sanctionswise';
this.client = axios.create({
baseURL: this.baseUrl,
headers: {
'x-api-key': this.apiKey,
'Content-Type': 'application/json'
},
timeout: 30000
});
}
async screenEntity(name, options = {}) {
const payload = {
name,
entity_type: options.entityType || 'individual',
threshold: options.threshold || 0.85
};
if (options.lists) payload.lists = options.lists;
if (options.identifiers) payload.identifiers = options.identifiers;
const response = await this.client.post('/screen/entity', payload);
return response.data;
}
async screenBatch(entities, options = {}) {
const payload = {
entities,
options: {
threshold: options.threshold || 0.85,
max_results_per_entity: options.maxResultsPerEntity || 5
}
};
if (options.lists) payload.options.lists = options.lists;
const response = await this.client.post('/screen/batch', payload, {
timeout: 120000
});
return response.data;
}
async getEntity(entityId) {
const response = await this.client.get(`/entities/${entityId}`);
return response.data;
}
async getLists() {
const response = await this.client.get('/lists');
return response.data;
}
}
// Usage
const client = new SanctionsWiseClient();
// Screen individual
client.screenEntity('Vladimir Putin', { threshold: 0.60 })
.then(result => {
console.log(`Status: ${result.status}, Matches: ${result.match_count}`);
});
// Batch screening
const entities = [
{ name: 'John Smith', entity_type: 'individual' },
{ name: 'Acme Corp', entity_type: 'organization' }
];
client.screenBatch(entities)
.then(result => {
console.log(`Clear: ${result.summary.clear}, Flagged: ${result.summary.potential_matches}`);
});
TypeScript Version​
import axios, { AxiosInstance } from 'axios';
interface ScreeningResult {
screening_id: string;
status: 'clear' | 'match' | 'potential_match';
matches: any[];
match_count: number;
timestamp: string;
}
interface BatchResult {
batch_id: string;
results: ScreeningResult[];
summary: {
total: number;
clear: number;
matches: number;
potential_matches: number;
};
}
class SanctionsWiseClient {
private client: AxiosInstance;
constructor(apiKey?: string) {
const key = apiKey || process.env.SANCTIONSWISE_API_KEY;
if (!key) throw new Error('API key required');
this.client = axios.create({
baseURL: 'https://api.orchestraprime.ai/sanctionswise',
headers: {
'x-api-key': key,
'Content-Type': 'application/json'
}
});
}
async screenEntity(name: string, threshold = 0.85): Promise<ScreeningResult> {
const { data } = await this.client.post('/screen/entity', { name, threshold });
return data;
}
async screenBatch(entities: Array<{name: string, entity_type?: string}>): Promise<BatchResult> {
const { data } = await this.client.post('/screen/batch', { entities });
return data;
}
}
export default SanctionsWiseClient;
Java​
Basic Client​
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class SanctionsWiseClient {
private static final String BASE_URL = "https://api.orchestraprime.ai/sanctionswise";
private final String apiKey;
private final HttpClient client;
public SanctionsWiseClient(String apiKey) {
this.apiKey = apiKey;
this.client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(30))
.build();
}
public String screenEntity(String name, String entityType, double threshold) throws Exception {
String requestBody = String.format(
"{\"name\":\"%s\",\"entity_type\":\"%s\",\"threshold\":%.2f}",
name, entityType, threshold
);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/screen/entity"))
.header("x-api-key", apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
throw new RuntimeException("API error: " + response.statusCode());
}
return response.body();
}
public String screenBatch(String entitiesJson) throws Exception {
String requestBody = String.format(
"{\"entities\":%s,\"options\":{\"threshold\":0.85}}",
entitiesJson
);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/screen/batch"))
.header("x-api-key", apiKey)
.header("Content-Type", "application/json")
.timeout(Duration.ofMinutes(2))
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
return response.body();
}
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("SANCTIONSWISE_API_KEY");
SanctionsWiseClient client = new SanctionsWiseClient(apiKey);
String result = client.screenEntity("Vladimir Putin", "individual", 0.60);
System.out.println(result);
}
}
cURL Examples​
Screen Single Entity​
curl -X POST "https://api.orchestraprime.ai/sanctionswise/screen/entity" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Vladimir Putin",
"entity_type": "individual",
"threshold": 0.60
}'
Batch Screening​
curl -X POST "https://api.orchestraprime.ai/sanctionswise/screen/batch" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"entities": [
{"name": "Vladimir Putin", "entity_type": "individual"},
{"name": "Bank of Russia", "entity_type": "organization"}
],
"options": {
"threshold": 0.60
}
}'
Get Entity Details​
curl "https://api.orchestraprime.ai/sanctionswise/entities/sw_ofac_sdn_35096" \
-H "x-api-key: YOUR_API_KEY"
List Sanctions Lists​
curl "https://api.orchestraprime.ai/sanctionswise/lists" \
-H "x-api-key: YOUR_API_KEY"