Integration Examples

Working code showing how to integrate OpenTrustToken into AI agents, payment flows, and applications.

Setup

Python SDK: pip install httpx (SDK is included in examples, will be on PyPI at launch)

Or just use the API directly: GET https://api.opentrusttoken.com/v1/check/{domain}

1. Basic Trust Check

Beginner

The simplest integration. Check a domain before making a payment. Act on the recommendation.

from opentrusttoken import check

result = check("stripe.com")

if result.is_blocked:
    print("Payment refused:", result.reasoning)
elif result.is_risky and amount > 100:
    print("Amount exceeds CAUTION limit. Need user approval.")
elif result.is_safe:
    print("Payment authorized.")

# Access signal details
print(result.trust_score)          # 83
print(result.signals.ssl.score)    # 100
print(result.jurisdiction.country) # "US"
Output: stripe.com
--- Attempting to pay $49.99 to stripe.com ---

Domain:         stripe.com
Trust Score:    83/100
Recommendation: PROCEED
Category:      infrastructure
Country:       US (US)

Signals:
  Reputation:  93/100
  Identity:    55/55
  Content:     95/100
  Domain Age:  100/100
  SSL/TLS:     100/100
  DNS:         60/100

SAFE: Established domain (5+ years), valid SSL, clean reputation.
Payment of $49.99 authorized.
Output: fake domain
--- Attempting to pay $899.00 to totally-fake-xyz123.com ---

Trust Score:    23/100
Recommendation: DENY
Flags:          NO_IDENTITY, NO_SSL

BLOCKED: no SSL detected, no identity verification on file.
Payment refused.

2. LangChain Agent

Intermediate

An AI agent that autonomously verifies merchants before purchasing. The agent decides on its own when to call the trust verification tool. Works with any LangChain-compatible LLM.

from langchain_openai import ChatOpenAI
from opentrusttoken.integrations.langchain import OTTVerifyTool

# Add the trust verification tool to your agent
llm = ChatOpenAI(model="gpt-4o")
tools = [OTTVerifyTool()]
agent = create_react_agent(llm, tools)

# The agent now checks merchants automatically
agent.invoke("Buy a USB-C cable from amazon.com for under $15")
Agent simulation output
TASK: Buy a USB-C cable from amazon.com for under $15

Agent: I need to buy from amazon.com.
Agent: Let me verify this merchant first...

[OTT Tool Response]
  amazon.com: Score 67/100 (CAUTION)
  Established domain, valid SSL, clean reputation.

Agent: This merchant scored 67 (CAUTION).
Agent: Amount $12.99 is within my CAUTION limit.
Agent: Proceeding with purchase at amazon.com.

TASK: Order a laptop from totally-fake-xyz123.com

[OTT Tool Response]
  totally-fake-xyz123.com: Score 23/100 (DENY)
  Flags: NO_IDENTITY, NO_SSL

Agent: This merchant failed trust verification (score: 23).
Agent: I cannot proceed. Searching for alternatives...

3. Multi-Merchant Comparison

Intermediate

Agent compares prices across multiple merchants, filters out untrustworthy ones, and recommends the best deal among verified options. The cheapest option ($9.99) gets rejected because it fails trust verification.

from opentrusttoken import OTTClient

client = OTTClient()
merchants = ["amazon.com", "ebay.com", "scosi.com",
             "totally-fake-xyz123.com", "bestbuy.com"]

for domain in merchants:
    result = client.check(domain)
    if result.is_blocked:
        print(f"REJECTED: {domain}")
    else:
        trusted.append(domain)
Output
Agent: Finding the best deal for a Wireless Mouse...

Domain                       Price   Score       Rec   Status
----------------------------------------------------------------------
amazon.com                 $ 29.99  67/100   CAUTION  CAUTION
ebay.com                   $ 24.99  78/100   PROCEED  TRUSTED
scosi.com                  $ 27.50  79/100   PROCEED  TRUSTED
totally-fake-xyz123.com    $  9.99  23/100     DENY  REJECTED
bestbuy.com                $ 31.99  55/100   CAUTION  CAUTION

Filtered out 1 untrustworthy merchant:
  totally-fake-xyz123.com (score 23, $9.99)

Best trusted deal: ebay.com at $24.99
  Trust score: 78/100 (PROCEED)

4. Async Batch Checking

Advanced

Check multiple domains concurrently. Useful for verifying a portfolio of merchants, building trust dashboards, or pre-screening a list of sites.

import asyncio
from opentrusttoken import OTTClient

async def batch_check():
    client = OTTClient()
    domains = ["stripe.com", "google.com", "amazon.com",
               "github.com", "cloudflare.com"]

    results = await client.async_check_multiple(domains)

    for r in sorted(results, key=lambda x: -x.trust_score):
        print(f"{r.domain}: {r.trust_score} ({r.recommendation})")

asyncio.run(batch_check())
Output (10 domains in 0.2s)
Checking 10 domains concurrently...

Domain                   Score       Rec      Category
----------------------------------------------------------------------
stripe.com               83/100   PROCEED   infrastructure
github.com               81/100   PROCEED   infrastructure
cloudflare.com           79/100   PROCEED   infrastructure
scosi.com                79/100   PROCEED   consumer
apple.com                79/100   PROCEED   consumer
ebay.com                 78/100   PROCEED   api_service
microsoft.com            77/100   PROCEED   consumer
shopify.com              75/100   PROCEED   api_service
google.com               73/100   CAUTION   api_service
amazon.com               67/100   CAUTION   consumer

Completed in 0.2s (0.0s per domain)
Summary: 8 PROCEED, 2 CAUTION, 0 DENY

5. Raw HTTP (Any Language)

Any Language

No SDK needed. The API is standard REST. Use curl, fetch, requests, or any HTTP client in any language.

# curl
curl https://api.opentrusttoken.com/v1/check/merchant.com

# JavaScript
const r = await fetch('https://api.opentrusttoken.com/v1/check/merchant.com');
const data = await r.json();
if (data.recommendation === 'DENY') throw new Error(data.reasoning);

# Go
resp, _ := http.Get("https://api.opentrusttoken.com/v1/check/merchant.com")

# Ruby
response = Net::HTTP.get(URI("https://api.opentrusttoken.com/v1/check/merchant.com"))
JSON Response
{
  "domain": "merchant.com",
  "trustScore": 81,
  "recommendation": "PROCEED",
  "reasoning": "Established domain, valid SSL...",
  "siteCategory": "consumer",
  "jurisdiction": { "country": "US", "crossBorderRisk": "standard" },
  "signals": { ... },
  "checklist": [ ... ],
  "signature": "z3FXQ...ed25519"
}