API Documentation
Access the full power of Synthex with our x402-powered API
Overview
The Synthex API uses the x402 protocol with PayAI facilitator to provide programmatic access to our AI-powered service search. We aggregate and index all available x402 services in real-time, giving you comprehensive coverage of the entire x402 ecosystem.
Cost: 0.001 USDC per search
Payment: via PayAI facilitator (Solana, Base, Polygon, Avalanche, Sei, Peaq, IoTeX)
✨ AI Summary Included: Each search includes an AI-generated analysis of the results, explaining why they match your query based on trust metrics, performance, and cost.
Quick Start
Install one of the x402 client packages to get started:
# Option 1: x402-fetch (recommended) npm install x402-fetch # Option 2: x402-axios npm install x402-axios axios
Endpoint
POST https://api.x402synthex.xyz/v1/x402/search
Payment is handled automatically by the x402 client packages via PayAI facilitator.
Request Format
{
"query": "payment gateway with low fees",
"limit": 10
}query(string) - Your search querylimit(number, optional) - Number of results (1-50, default: 10)
Response Format
{
"aiSummary": "Based on your search for payment gateways...",
"services": [
{
"resource": "https://example.com/payment-api",
"description": "Low-fee payment gateway supporting multiple chains",
"cost": "1000000",
"network": "base",
"trust_score": 0.85,
"performance_score": 0.90,
"final_score": 0.87
}
],
"total_found": 10
}Code Examples
JavaScript (x402-fetch) ⭐ Recommended
import { Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { decodeXPaymentResponse, wrapFetchWithPayment } from "x402-fetch";
const privateKey = process.env.PRIVATE_KEY as Hex;
const url = "https://api.x402synthex.xyz/v1/x402/search";
const account = privateKeyToAccount(privateKey);
const fetchWithPayment = wrapFetchWithPayment(fetch, account);
fetchWithPayment(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
query: "decentralized storage with low latency",
limit: 10
})
})
.then(async response => {
const data = await response.json();
console.log(data);
// Extract payment confirmation
const paymentResponse = decodeXPaymentResponse(
response.headers.get("x-payment-response")!
);
console.log("Transaction:", paymentResponse.transactionHash);
})
.catch(error => {
console.error(error);
});JavaScript (x402-axios)
import axios from 'axios';
import { withPaymentInterceptor } from 'x402-axios';
const client = withPaymentInterceptor(axios.create());
const { data } = await client.post(
'https://api.x402synthex.xyz/v1/x402/search',
{
query: 'decentralized storage',
limit: 10
}
);
console.log('AI Summary:', data.aiSummary);
console.log(`Found ${data.total_found} services`);cURL (using npx)
npx x402-fetch POST https://api.x402synthex.xyz/v1/x402/search \
-H "Content-Type: application/json" \
-d '{"query":"decentralized storage","limit":10}'Python
# Use the Python equivalent of x402-fetch # Visit x402.org for Python SDK documentation
Payment via PayAI
All payments are processed through the PayAI facilitator, which handles the x402 protocol automatically when using the recommended client packages.
PayAI Facilitator
Cost: 0.001 USDC per search
The x402 client packages handle payment automatically. You just need a wallet with 0.001 USDC on one of the supported networks.
Learn more: For complete implementation details, visit PayAI Documentation or the official x402 protocol documentation.
Support
Need help integrating the API? Have questions about pricing or features?
Get in Touch