import requests
from langchain.tools import tool
ENCRATA_API_KEY = "YOUR_API_KEY"
BASE_URL = "https://developer.encrata.com/api/lookup/email"
HEADERS = {
"Authorization": f"Bearer {ENCRATA_API_KEY}",
"Content-Type": "application/json",
}
@tool
def lookup_email(email: str) -> dict:
"""Look up detailed intelligence about a person by their email address.
Returns name, company, job role, industry, location, and social
profiles. Costs 1,000 credits."""
resp = requests.post(
f"{BASE_URL}/identity",
headers=HEADERS,
json={"email": email},
)
resp.raise_for_status()
return resp.json()
@tool
def validate_email(email: str) -> dict:
"""Validate whether an email address is deliverable, invalid,
or disposable. Costs 1 credit; repeat lookups within the billing window are free."""
resp = requests.post(
f"{BASE_URL}/validity",
headers=HEADERS,
json={"email": email},
)
resp.raise_for_status()
return resp.json()
@tool
def check_breaches(email: str) -> dict:
"""Check if an email has been exposed in known data breaches.
Returns breach count, affected services, and exposed data types.
Costs 1 credit; repeat lookups within the billing window are free."""
resp = requests.post(
f"{BASE_URL}/breaches",
headers=HEADERS,
json={"email": email},
)
resp.raise_for_status()
return resp.json()