@xpaysh/agent-kit-testing
v0.1.1
Published
Mock payment-protected API server for testing agents (supports x402, AP2, etc.)
Maintainers
Readme
@xpaysh/agent-kit-testing
Mock payment-protected API server for testing AI agents with x402 micropayments.
Overview
A fully-featured mock API server with x402 payment protection for testing and developing AI agents. Includes multiple endpoints with different pricing tiers, perfect for development and integration testing.
Features
- Payment-Protected Endpoints: Weather, crypto, news, and data analysis APIs
- Free Endpoints: Health check and utility endpoints for testing
- Variable Pricing: Different price points for testing spending controls
- Express Integration: Built with x402-express middleware
- Easy Setup: Run locally or deploy for team testing
Installation
npm install @xpaysh/agent-kit-testingQuick Start
import express from 'express';
import { paymentMiddleware } from 'x402-express';
// Or use the pre-built server
import './node_modules/@xpaysh/agent-kit-testing/dist/server.js';Running the Mock Server
# Install
npm install @xpaysh/agent-kit-testing
# Run
npx @xpaysh/agent-kit-testingOr set environment variables:
PORT=3001
PAY_TO_ADDRESS=0x742d35Cc6634C0532925a3b844D2dF1e6fc2e8666
npm startAvailable Endpoints
Free Endpoints
GET /health- Health checkGET /api/free/time- Current server timePOST /api/free/echo- Echo any JSON payload
Paid Endpoints (x402 Protected)
GET /api/weather- Weather data ($0.01 per request)GET /api/crypto- Cryptocurrency prices ($0.005 per request)GET /api/news- News articles ($0.02 per request)POST /api/analyze- Data analysis ($0.05 per request)
Testing Your Agent
import { SmartProxy } from '@xpaysh/agent-kit-core';
const smartProxy = new SmartProxy({
privateKey: process.env.PRIVATE_KEY,
network: 'base-sepolia',
spendingLimits: { dailyLimit: 1 }
});
// Test against mock server
const weather = await smartProxy.protectedFetch('http://localhost:3001/api/weather');
console.log('Weather data:', weather.data);
console.log('Cost:', weather.cost); // $0.01Documentation
For comprehensive documentation, guides, and examples, visit:
- Documentation: https://docs.xpay.sh
- Website: https://www.xpay.sh
Links
License
MIT © xPay
