๐Ÿ“ก REST API v1

API Reference

The TrustGrade API provides programmatic access to trust scores for crypto entities. All endpoints return JSON. Base URL: https://api.trustgrade.ai

Authentication

All endpoints except /v1/health and /v1/stats require a Bearer token. Get your API key from the TrustGrade dashboard.

http Auth Header
Authorization: Bearer tg_live_xxxxxxxxxxxxxxxxxxxxxxxx

Rate Limits

TierLimitPriceBest For
Free100 requests/day$0Testing & prototypes
Builder25,000 requests/day$49/moProduction agents
Pro250,000 requests/day$199/moHigh-volume platforms
EnterpriseUnlimitedCustomInstitutional

Rate limit headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.

Public Endpoints

GET /v1/health

Health check. No authentication required.

bash
curl https://api.trustgrade.ai/v1/health

# Response:
{
  "status": "ok",
  "version": "2.0.0",
  "timestamp": "2026-07-12T10:54:46.487Z"
}

GET /v1/stats

Protocol statistics. No authentication required.

bash
curl https://api.trustgrade.ai/v1/stats

# Response:
{
  "totalEntities": 45,
  "entityTypes": 8,
  "avgScore": 82,
  "avgResponseTime": "47ms",
  "lastUpdate": "2026-07-12T10:54:46.487Z"
}

GET /v1/entity-types

List all supported entity types for trust scoring.

bash
curl https://api.trustgrade.ai/v1/entity-types

# Response:
{
  "types": [
    { "type": "defi_protocol", "name": "DeFi Protocol" },
    { "type": "stablecoin", "name": "Stablecoin" },
    { "type": "ai_agent", "name": "AI Agent" },
    { "type": "smart_contract", "name": "Smart Contract" },
    { "type": "token", "name": "Token" },
    { "type": "nft_collection", "name": "NFT Collection" },
    { "type": "dao", "name": "DAO" }
  ]
}

GET /v1/score/:type/:id

Retrieve a cached trust score for a specific entity. Requires authentication.

bash Cached Score Lookup
curl https://api.trustgrade.ai/v1/score/defi_protocol/Uniswap \
  -H "Authorization: Bearer $TRUSTGRADE_KEY"

# Response:
{
  "entity": "Uniswap",
  "type": "defi_protocol",
  "score": 100,
  "grade": "A+",
  "confidence": 0.8837,
  "summary": "Exceptional trust profile. TVL stability and audit coverage above average.",
  "breakdown": {
    "wilson": 0.9855,
    "bayesian": 0.7866,
    "incidentPenalty": 0,
    "volumeBonus": 7.25
  },
  "computedAt": "2026-07-12T10:54:46.480Z"
}

POST /v1/score โ€” Compute Trust Score

Compute a fresh trust score from raw signals. Accepts two formats: v1 core signals (simple) and v2 timestamped signals (advanced).

Request Body (v1 Core Signals)

FieldTypeRequiredDescription
entityTypestringYesEntity type (e.g. defi_protocol)
entityIdstringYesEntity name or identifier
core.successRatenumber (0โ€“1)YesObserved positive outcome rate
core.sampleSizenumberYesTotal observations backing successRate
core.verificationRatenumber (0โ€“1)YesSecondary verification rate
core.incidentSharenumber (0โ€“1)YesShare of incidents/anomalies
optionalsOptionalSignal[]NoEntity-specific weighted signals
bash v1 Core Signals
curl -X POST https://api.trustgrade.ai/v1/score \
  -H "Authorization: Bearer $TRUSTGRADE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "entityType": "defi_protocol",
    "entityId": "MyProtocol",
    "core": {
      "successRate": 0.95,
      "sampleSize": 500,
      "verificationRate": 0.88,
      "incidentShare": 0.02
    },
    "optionals": [
      {
        "key": "tvl_stability",
        "label": "TVL Stability (30-day)",
        "value": 0.93,
        "weight": 14
      },
      {
        "key": "audit_coverage",
        "label": "Audit Coverage",
        "value": 1.0,
        "weight": 16
      }
    ]
  }'
bash v2 Timestamped Signals
// v2 timestamped signals format
curl -X POST https://api.trustgrade.ai/v1/score \
  -H "Authorization: Bearer $TRUSTGRADE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "entityType": "stablecoin",
    "entityId": "MYUSD",
    "version": 2,
    "signals": [
      {
        "key": "successRate",
        "value": 0.97,
        "timestamp": "2026-07-12T10:00:00Z"
      },
      {
        "key": "sampleSize",
        "value": 1200,
        "timestamp": "2026-07-12T10:00:00Z"
      },
      {
        "key": "verificationRate",
        "value": 0.92,
        "timestamp": "2026-07-12T10:00:00Z"
      },
      {
        "key": "incidentShare",
        "value": 0.01,
        "timestamp": "2026-07-12T10:00:00Z"
      }
    ],
    "optionals": [...]
  }'

Scoring Methodology

The TrustGrade Score is a composite of five mathematical layers:

1. Wilson Score Lower Bound

W = (p + zยฒ/2n โˆ’ zยทโˆš(p(1โˆ’p)/n + zยฒ/4nยฒ)) / (1 + zยฒ/n)

The conservative lower bound of the 95% confidence interval for a binomial proportion. Requires substantial evidence to score high โ€” 95% success over 10 samples doesn't cut it. z = 1.96 (95% CI) for most entities; z = 2.24 (97.5% CI) for stablecoins.

2. Bayesian Beta Posterior

B = (vยทn + ฮฑโ‚€) / (n + ฮฑโ‚€ + ฮฒโ‚€)

Sceptical Beta(ฮฑโ‚€, ฮฒโ‚€) prior updated with observed data. When sample size is small, the estimate shrinks toward the conservative prior mean. Default: ฮฑโ‚€=2, ฮฒโ‚€=5.

3. Compound Incident Penalty

P = 1 โˆ’ (1 โˆ’ s)ยฒ

Quadratic penalty on incident share. Grows faster than linear: 10% incidents โ†’ 19% penalty, 30% โ†’ 51%, 50% โ†’ 75%. This ensures repeated incidents compound rather than average out.

4. Log-Credibility Volume Bonus

B = min(cap, logโ‚โ‚€(n) ร— k)

Rewards sample size on a logarithmic scale. 100 samples โ†’ ~2ร—k bonus. 1000 โ†’ ~3ร—k. Diminishing returns prevent large datasets from dominating. Cap depends on entity type.

5. Optional Weighted Signals

contribution = (value โˆ’ 0.5) ร— weight

Each entity type defines its own signals (TVL stability, audit coverage, exploit history, etc.). Value normalized to [0,1]. Contribution ranges from โˆ’weight/2 (worst) to +weight/2 (best).

Composite Score Formula

text Composite Formula
score = round(clamp(
  W ร— wilsonWeight
  + B ร— bayesianWeight
  + volumeBonus
  - P ร— incidentWeight
  + ฮฃ(optional contributions)
, 0, 100))

Grade Thresholds

ScoreGradeColor
97โ€“100A+๐ŸŸข Green
93โ€“96A๐ŸŸข Green
90โ€“92Aโˆ’๐ŸŸข Teal
87โ€“89B+๐ŸŸข Dark Green
83โ€“86B๐ŸŸข Lime
80โ€“82Bโˆ’๐ŸŸข Light Lime
75โ€“79C+๐ŸŸก Amber
70โ€“74C๐ŸŸก Amber
65โ€“69Cโˆ’๐ŸŸก Light Amber
60โ€“64D+๐ŸŸ  Orange
55โ€“59D๐ŸŸ  Orange
50โ€“54Dโˆ’๐ŸŸ  Light Orange
0โ€“49F๐Ÿ”ด Red

CoreSignals Schema

Required for every score computation. These are the non-negotiable inputs.

FieldTypeRangeDescription
successRatenumber0โ€“1Observed success/positive rate. For DeFi: audit pass rate. For stablecoins: peg stability. For agents: transaction success rate.
sampleSizenumberโ‰ฅ0Total observations. More data = higher volume bonus and Wilson confidence.
verificationRatenumber0โ€“1Secondary verification rate (e.g. on-chain verification percentage).
incidentSharenumber0โ€“1Share of flagged incidents/anomalies. Feeds compound penalty.

OptionalSignal Schema

Entity-specific weighted signals. Each entity type defines its own set.

FieldTypeRangeDescription
keystringโ€”Unique identifier (e.g. tvl_stability)
labelstringโ€”Human-readable label
valuenumber | null0โ€“1Normalized signal value. null = not available.
weightnumberโ€”Max absolute point contribution. Contribution = (value โˆ’ 0.5) ร— weight.

Error Codes

CodeMeaningWhen
400Bad RequestInvalid input โ€” missing required fields, values out of range
401UnauthorizedMissing or invalid API key
404Not FoundEntity not in registry (for cached lookups)
429Rate LimitedExceeded daily request quota. Check X-RateLimit-Reset.
500Internal ErrorScoring engine failure. Retry with exponential backoff.
json Error Response
// 429 Response example
{
  "error": "Rate limit exceeded",
  "message": "Daily quota of 100 requests exceeded. Resets at 00:00 UTC.",
  "retryAfter": 3600,
  "tier": "free"
}

SDK Examples

Python

python agent.py
pip install trustgrade

from trustgrade import TrustGrade

client = TrustGrade(api_key="tg_live_xxx")

# Cached score lookup
score = client.score("defi_protocol", "Uniswap")
print(f"{score.entity}: {score.grade} ({score.score}/100)")

# Compute new score
result = client.compute(
    entity_type="defi_protocol",
    entity_id="MyProtocol",
    core={
        "successRate": 0.95,
        "sampleSize": 500,
        "verificationRate": 0.88,
        "incidentShare": 0.02
    },
    optionals=[
        {"key": "tvl_stability", "label": "TVL Stability", "value": 0.93, "weight": 14}
    ]
)
print(f"Computed: {result.grade} ({result.score}/100)")

JavaScript / TypeScript

javascript agent.ts
npm install @trustgrade/sdk

import { TrustGrade } from '@trustgrade/sdk';

const tg = new TrustGrade({ apiKey: process.env.TRUSTGRADE_KEY });

// Cached lookup
const score = await tg.score('stablecoin', 'USDC');
console.log(`${score.entity}: ${score.grade} (${score.score}/100)`);

// Compute new
const result = await tg.compute({
  entityType: 'defi_protocol',
  entityId: 'MyProtocol',
  core: {
    successRate: 0.95,
    sampleSize: 500,
    verificationRate: 0.88,
    incidentShare: 0.02,
  },
  optionals: [
    { key: 'tvl_stability', label: 'TVL Stability', value: 0.93, weight: 14 }
  ],
});

cURL

bash Quick Start
# Set your API key
export TRUSTGRADE_KEY="tg_live_xxx"

# Check a score
curl -s https://api.trustgrade.ai/v1/score/stablecoin/USDC \
  -H "Authorization: Bearer $TRUSTGRADE_KEY" | jq .grade
# โ†’ "B-"