💳 Pay‑per‑call with x402
Use your crypto wallet to pay per API call using x402. No API key is required when using x402.
📺 Integration Tutorials & Demos
- x402 Tutorial Watch on YouTube ⤴
How it works
- Set up an x402 client by following the official Quickstart for Buyers guide: x402 Quickstart for Buyers
- Call any endpoint and add these headers:
x-coinbase-402: true
(required) — tells our API to handle this as an x402 payment flowx-payment-token: usdc | tmai
(optional) — choose the token to pay with. Defaults tousdc
. Usingtmai
applies a 10% discount to the charge amount
- Do not send
x-api-key
when using x402 — your wallet and x402 handle payment and access
Minimal examples
Node.js (Axios + x402)
import axios from "axios";
import { withPaymentInterceptor } from "x402-axios";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";
// Create a wallet account per the x402 Quickstart
const account = privateKeyToAccount(process.env.PRIVATE_KEY);
// Wrap axios instance with x402 payment handling (pass your wallet account)
const api = withPaymentInterceptor(
axios.create({ baseURL: "https://api.tokenmetrics.com" }),
account,
);
const res = await api.get("/v2/trading-signals", {
headers: {
"x-coinbase-402": "true",
"x-payment-token": "usdc", // or "tmai" for 10% discount
},
});
console.log(res.data);
Python (HTTPX + x402)
from x402.clients.httpx import x402HttpxClient
from eth_account import Account
import asyncio
import os
async def main():
# Create a wallet account per the x402 Quickstart
account = Account.from_key(os.environ["PRIVATE_KEY"])
# Use x402 HTTPX client with your wallet account
async with x402HttpxClient(account=account, base_url="https://api.tokenmetrics.com") as client:
r = await client.get(
"/v2/trading-signals",
headers={
"x-coinbase-402": "true",
"x-payment-token": "tmai", # 10% discount
},
)
print(await r.aread())
asyncio.run(main())
For full x402 client setup and additional samples, see the official docs: x402 Quickstart for Buyers.
Spending limit for TMAI payments (important)
When paying with tmai
, please set a maximum amount your wallet is allowed to spend for the request in your x402 client. tmai
uses 18 decimals, so values are represented in very small units. To make this simple: set the max to the equivalent of up to 200 TMAI.
- Node.js (BigInt in wei, the smallest unit):
// 200 TMAI in base units (wei): 200 * 10^18
const maxTmaiWei = 200n * 1000000000000000000n;
// Pass this as the max/spend limit to your x402 client options
// Example (option name may vary by client):
// const api = withPaymentInterceptor(axios.create({ baseURL }), account, { maxPayment: maxTmaiWei });
- Python:
# 200 TMAI in base units (wei): 200 * 10^18
max_tmai_wei = 200 * (10 ** 18)
# Pass this as the max/spend limit to your x402 client options
# Example (option name may vary by client):
# async with x402HttpxClient(account=account, base_url=base_url, max_payment=max_tmai_wei) as client:
This simply means “allow up to 200 TMAI to be chargeable for this call.” You can pick a different limit if you prefer. If you don’t set this for TMAI, the payment may fail if your client’s default max is too low. For usdc
(6 decimals) this is typically not required, but you may still set a limit if you want.
API Endpoints Pricing for Pay-per-call
🆓 Free Endpoints (No Payment Required)
Endpoint | Description |
---|---|
/v2/tokens | Token metadata and IDs |
/v2/price | Live price streams |
/v2/top-market-cap-tokens | Tokens ranked by market cap |
💡 $0.017 USDC / $0.0153 TMAI
Endpoint | Description |
---|---|
/v2/trading-signals | Entry/exit signals |
/v2/hourly-ohlcv | Hourly historical prices |
/v2/daily-ohlcv | Daily historical prices |
💼 $0.034 USDC / $0.0306 TMAI
Endpoint | Description |
---|---|
/v2/resistance-support | Price levels & volatility |
/v2/market-metrics | Bullish/Bearish indicators |
/v2/indices | AI-powered crypto indices |
/v2/indices-holdings | Index components |
/v2/indices-performance | Index returns |
/v2/hourly-trading-signals | Frequent short-term signals |
/v2/tm-grade | Gets the latest TM Grade for a token—including quant grade, buy/sell signals, momentum, and 24-hour percentage changes. |
/v2/tm-grade-history | Historical TM Grade with buy/sell signal trends and momentum changes over time. |
/v2/technology-grade | Latest technology grade covering development activity, security, and innovation. |
/v2/technology-grade-history | Latest technology grade covering development activity, security, and innovation. |
/v2/fundamental-grade | Latest fundamental grade based on project quality, adoption, and market potential. |
/v2/fundamental-grade-history | Historical fundamental grade trends over time. |
🚀 $0.068 USDC / $0.0612 TMAI
Endpoint | Description |
---|---|
/v2/correlation | Token correlation analytics |
/v2/price-prediction | Price prediction of a crypto asset under different market cap scenarios. |
/v2/ai-reports | Token/market research |
/v2/quantmetrics | Investor activity & ranking |
/v2/crypto-investors | On-chain investor tracking |
/v2/moonshot-tokens | AI-curated high potential tokens |
/v2/tmai | Token Metrics AI Chatbot |
Updated 5 days ago