POST
/api/crypto-price$0.001📊 Crypto Price
Fetch real-time cryptocurrency prices, 24-hour price change, and market capitalization data from CoinGecko. Supports any coin ID or ticker symbol.
Request Body
Response Fields
Code Examples
cURL
bash
curl -X POST https://sparkforge.sh/api/crypto-price \
-H "Content-Type: application/json" \
-H "X-PAYMENT: <x402-payment-token>" \
-d '{"symbol": "BTC"}'Python
python
import requests
response = requests.post(
"https://sparkforge.sh/api/crypto-price",
headers={"Content-Type": "application/json", "X-PAYMENT": "<token>"},
json={"symbol": "ETH"}
)
data = response.json()
print(f"${data['price_usd']:,.2f} ({data['change_24h']:+.1f}%)")TypeScript / Node.js
typescript
const res = await fetch402("https://sparkforge.sh/api/crypto-price", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ symbol: "BTC" }),
});
const { price_usd, change_24h, market_cap } = await res.json();Example Response
json
{
"symbol": "BTC",
"name": "Bitcoin",
"price_usd": 84521.30,
"change_24h": 2.34,
"market_cap": 1673000000000,
"volume_24h": 28400000000
}💳 Payment via x402
This endpoint costs $0.001 per call, paid in USDC on Base, Polygon, or Solana. Use the @x402/fetch library to handle payments automatically, or implement the x402 handshake manually.
bash
# Free demo mode (no payment)
curl https://sparkforge.sh/api/crypto-price?demo=true
# Or try via MCP (Claude Desktop, Cursor, Windsurf)
# Add to mcp config: { "url": "https://sparkforge.sh/api/mcp" }