import json
import requests
from llama_index.core.tools import FunctionTool
ENCRATA_API_KEY = "YOUR_API_KEY"
BASE_URL = "https://encrata.com/api/agent"
HEADERS = {
"Authorization": f"Bearer {ENCRATA_API_KEY}",
"Content-Type": "application/json",
}
def lookup_email(email: str) -> str:
"""Look up detailed intelligence about a person by their email address.
Returns name, company, job role, industry, location, social profiles,
breach history, and email validity. Costs 1 credit."""
resp = requests.post(
f"{BASE_URL}/lookup",
headers=HEADERS,
json={"email": email},
)
resp.raise_for_status()
return json.dumps(resp.json(), indent=2)
def validate_email(email: str) -> str:
"""Validate whether an email address is deliverable, invalid,
or disposable. Free — does not cost credits."""
resp = requests.post(
f"{BASE_URL}/validate",
headers=HEADERS,
json={"email": email},
)
resp.raise_for_status()
return json.dumps(resp.json(), indent=2)
def check_breaches(email: str) -> str:
"""Check if an email has been exposed in known data breaches.
Returns breach count, affected services, and exposed data types.
Free — does not cost credits."""
resp = requests.post(
f"{BASE_URL}/breaches",
headers=HEADERS,
json={"email": email},
)
resp.raise_for_status()
return json.dumps(resp.json(), indent=2)
lookup_tool = FunctionTool.from_defaults(fn=lookup_email)
validate_tool = FunctionTool.from_defaults(fn=validate_email)
breach_tool = FunctionTool.from_defaults(fn=check_breaches)