Documentation Index
Fetch the complete documentation index at: https://docs.monkepay.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Installation
npm install @monkepay/sdk hono
Basic usage
import { Hono } from 'hono'
import { MonkePayHono } from '@monkepay/sdk'
const app = new Hono()
const monkePay = MonkePayHono({
apiKeyId: process.env.MONKEPAY_API_KEY_ID!,
apiKeySecret: process.env.MONKEPAY_API_KEY_SECRET!,
price: '0.001',
})
// Gate all routes under /api
app.use('/api/*', monkePay())
app.get('/api/data', (c) => c.json({ result: 'paid content' }))
app.get('/api/other', (c) => c.json({ result: 'also paid' }))
Per-route pricing
MonkePayHono returns a factory. Call it with optional overrides to get middleware for a specific route:
const monkePay = MonkePayHono({
apiKeyId: process.env.MONKEPAY_API_KEY_ID!,
apiKeySecret: process.env.MONKEPAY_API_KEY_SECRET!,
price: '0.001', // default
})
app.use('/api/cheap', monkePay({ price: '0.001' }))
app.use('/api/expensive', monkePay({ price: '0.10' }))
app.use('/api/report', monkePay({ price: '1.00', paymentMode: 'one_time' }))
app.get('/api/cheap', (c) => c.json({ result: 'cheap' }))
app.get('/api/expensive', (c) => c.json({ result: 'expensive' }))
app.get('/api/report', (c) => c.json({ result: 'one-time report' }))
With Hono serve
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
import { MonkePayHono } from '@monkepay/sdk'
const app = new Hono()
const monkePay = MonkePayHono({
apiKeyId: process.env.MONKEPAY_API_KEY_ID!,
apiKeySecret: process.env.MONKEPAY_API_KEY_SECRET!,
price: '0.001',
})
app.use('/api/*', monkePay())
app.get('/api/data', (c) => c.json({ hello: 'world' }))
serve({ fetch: app.fetch, port: 3000 })
Notes
baseUrl has no effect for Hono. Resource URL construction is handled internally by x402-hono. Hono handles proxy headers automatically in most runtimes — if you’re behind a reverse proxy and seeing incorrect resource URLs, configure proxy trust at the runtime/infrastructure level instead.
Works in all Hono runtimes — Node.js, Bun, Cloudflare Workers, Deno. The SDK uses standard Web Crypto and fetch APIs with no Node-specific dependencies.