Coding Examples

Seamlessly integrate OFAC screening into your backend workflows for automated compliance.

Use Case: Customer Screening

An insurance provider needs to screen new or modified customers against OFAC/Other lists. This API allows you to automate that process securely and efficiently.

Example: Screening a legacy entity like IRAN PETROCHEMICAL COMMERCIAL COMPANY during onboarding or profile update.

Sample Request Payload


	{
	"apiKey": "your-api-key",
	"ofacId": 1001,
	"word1": "IRAN",
	"word2": "PETROCHEMICAL",
	"word3": "COMMERCIAL",
	"word4": "COMPANY",
	"word5": "",
	"city": "",
	"country": "",
	"searchComments": "Legacy entity screening"
	}

Example C# Code



	//	Install-Package System.Net.Http.Json
	//	Install-Package Microsoft.AspNet.WebApi.Client
	using var client = new HttpClient();
	client.BaseAddress = new Uri("https://ofacapi.com");

	var request = new {
	apiKey = "your-api-key",
	ofacId = 1001,
	word1 = "IRAN",
	word2 = "PETROCHEMICAL",
	word3 = "COMMERCIAL",
	word4 = "COMPANY",
	word5 = "",
	city = "",
	country = "",
	searchComments = "Legacy entity screening",
	source = "InsuranceCRM"
	};

	var response = await client.PostAsJsonAsync("/api/search", request);

	if (response.IsSuccessStatusCode) {
	var result = await response.Content.ReadAsAsync<OfacResult>();
	if (result.matches.Any(m => m.score > 85)) {
	// Flag customer and notify compliance
	}
	}

Example Python Code


	import requests
	import json
	from typing import Dict, Optional

	class OFACSearchClient:
	def __init__(self, api_key: str, ofac_id: int):
	"""Initialize the OFAC Search client with API credentials."""
	self.base_url = "https://ofacapi.com"
	self.api_key = api_key
	self.ofac_id = ofac_id
	self.headers = {
	"Content-Type": "application/json",
	"Accept": "application/json"
	}

	def search(self,
	word1: str,
	lists_to_search: int = 1,
	data_type: int = 1,
	source: str = "PY",
	word2: str = "",
	word3: str = "",
	word4: str = "",
	word5: str = "",
	street: str = "",
	city: str = "",
	st_prov: str = "",
	postal_code: str = "",
	country: str = "",
	dob: str = "",
	search_comments: str = "") -> Optional[Dict]:
	"""
	Perform an OFAC search with the provided parameters.

	Args:
	word1: Primary search term (required, 3-100 characters)
	lists_to_search: Lists to search (default: 1)
	data_type: Type of data to search (default: 1)
	source: Source identifier (max 2 characters, default: "PY")
	word2-5: Additional search terms (max 100 characters each)
	street: Street address (max 100 characters)
	city: City (max 100 characters)
	st_prov: State/Province (max 20 characters)
	postal_code: Postal code (max 20 characters)
	country: Country (max 50 characters)
	dob: Date of birth (max 20 characters)
	search_comments: Search comments (max 125 characters)

	Returns:
	Dict containing search results or None if request fails
	"""
	# Construct the request payload
	payload = {
	"ofacId": self.ofac_id,
	"apiKey": self.api_key,
	"listsToSearch": lists_to_search,
	"dataType": data_type,
	"word1": word1,
	"word2": word2,
	"word3": word3,
	"word4": word4,
	"word5": word5,
	"street": street,
	"city": city,
	"stProv": st_prov,
	"postalCode": postal_code,
	"country": country,
	"dob": dob,
	"searchComments": search_comments
	}

	try:
	# Make the POST request to the API
	response = requests.post(
	f"{self.base_url}/api/Search",
	headers=self.headers,
	json=payload,
	timeout=10
	)

	# Check if request was successful
	response.raise_for_status()

	# Return the JSON response
	return response.json()

	except requests.exceptions.RequestException as e:
	print(f"Error making request to OFAC API: {str(e)}")
	return None

	def main():
	# Example usage
	API_KEY = "09999999-ABCD-101F"  # Replace with your actual API key
	OFAC_ID = 99999  # Replace with your actual OFAC ID

	# Create client instance
	client = OFACSearchClient(api_key=API_KEY, ofac_id=OFAC_ID)

	# Perform a search
	result = client.search(
	word1="putin",
	country="USA",
	search_comments="Test search"
	)

	# Print results
	if result:
	print("Search Results:")
	print(f"OFAC ID: {result.get('ofacId')}")
	print(f"Search Key: {result.get('searchKey')}")
	print(f"Found: {result.get('found')}")
	else:
	print("Search failed")

	if __name__ == "__main__":
	main()

Test It Live

Use Swagger UI to explore and test the API:

Swagger