trustlayer-sdk
v0.1.0
Published
Reputation intelligence for AI agents — trust scores, Sybil detection, cross-chain identity
Downloads
14
Maintainers
Readme
trustlayer-sdk
Reputation intelligence for AI agents. Trust scores, Sybil detection, and cross-chain identity resolution for 133K+ agents across 20 blockchains.
Zero dependencies. Uses native fetch.
Install
npm install trustlayer-sdkQuick Start
import { TrustLayer } from 'trustlayer-sdk'
const tl = new TrustLayer()
// Full trust report
const report = await tl.trust('base:1378')
console.log(report.trust_score) // 73
console.log(report.sybil_risk) // "medium"
console.log(report.risk_level) // "medium"
// Gate check before transacting
const gate = await tl.gate('base:1378', 80)
if (gate.passed) {
// safe to proceed
}API
new TrustLayer(options?)
| Option | Type | Default |
|--------|------|---------|
| baseUrl | string | https://api.thetrustlayer.xyz |
| timeout | number | 30000 (ms) |
Methods
| Method | Description | Returns |
|--------|-------------|---------|
| trust(agentId) | Full Sybil forensics report | TrustReport |
| score(agentId) | Basic trust score (same endpoint as trust) | TrustReport |
| gate(agentId, threshold?) | Pass/fail gate check (default threshold: 80) | GateResult |
| leaderboard(chain?, limit?) | Top agents by trust score | LeaderboardResponse |
| stats() | Network-wide stats | StatsResponse |
Agent IDs use chain:id format: base:1378, ethereum:42, bsc:100, polygon:56, monad:1000.
Error Handling
import { TrustLayer, TrustLayerError } from 'trustlayer-sdk'
const tl = new TrustLayer()
try {
const report = await tl.trust('base:9999999')
} catch (err) {
if (err instanceof TrustLayerError) {
console.log(err.status) // 404
console.log(err.body) // { error: "Agent not found" }
}
}TypeScript Types
All response types are exported:
import type {
TrustReport,
GateResult,
LeaderboardEntry,
LeaderboardResponse,
StatsResponse,
TrustLayerOptions,
} from 'trustlayer-sdk'CommonJS
const { TrustLayer } = await require('trustlayer-sdk')
// or use ESM import (recommended)Links
- API docs: https://api.thetrustlayer.xyz/openapi.json
- Website: https://thetrustlayer.xyz
- Python SDK: https://pypi.org/project/trustlayer-sdk/
