Connect to ws://localhost:8080
to interact with the server.
All messages follow this format:
{
"action": "action_name",
"status": "success|error",
... additional fields
}
// Request
{
"action": "convert_price",
"quote_currency": "BTC",
"base_currency": "USD",
"quote_value": 1
}
// Response
{
"status": "success",
"data": {
"quote_currency": "BTC",
"base_currency": "USD",
"quote_value": 1,
"base_value": 43000.00,
"timestamp": "2024-01-01T12:00:00Z"
}
}
// Request
{
"action": "list_prices"
}
// Response
{
"status": "success",
"data": [
{
"id": "price_123",
"currency": "BTC",
"value": 43000.00,
"createdAt": "2024-01-01T12:00:00Z",
"updatedAt": "2024-01-01T12:00:00Z"
}
]
}
// Request
{
"action": "create_invoice",
"amount": 1000,
"currency": "USD",
"account_id": 1,
"webhook_url": "https://example.com/webhook",
"redirect_url": "https://example.com/return",
"memo": "Payment for services"
}
// Response
{
"status": "success",
"data": {
"invoice": {
"uid": "inv_123",
"amount": 1000,
"currency": "USD",
"status": "unpaid",
"created_at": "2024-01-01T12:00:00Z"
}
}
}
// Request
{
"action": "fetch_invoice",
"id": "inv_123"
}
// Response
{
"status": "success",
"data": {
"uid": "inv_123",
"amount": 1000,
"currency": "USD",
"status": "unpaid",
"created_at": "2024-01-01T12:00:00Z"
}
}
// Request
{
"action": "subscribe",
"type": "invoice|account|address",
"id": "resource_id"
}
// Response
{
"status": "success",
"message": "Subscribed to invoice resource_id"
}
// Event Message
{
"type": "invoice.updated",
"data": {
"id": "inv_123",
"status": "paid",
"updated_at": "2024-01-01T12:00:00Z"
}
}
// Request
{
"action": "unsubscribe",
"type": "invoice|account|address",
"id": "resource_id"
}
// Response
{
"status": "success",
"message": "Unsubscribed from invoice resource_id"
}
The WebSocket server emits various events that you can subscribe to:
invoice.created
- New invoice createdinvoice.updated
- Invoice status changedpayment.received
- Payment detectedprice.updated
- Price update received
Get current prices for all supported currencies.
Response:
{
"prices": [
{
"currency": "BTC",
"base": "USD",
"value": 43000.00,
"updatedAt": "2024-01-01T12:00:00Z",
"source": "coinbase"
}
]
}
Create a new payment request.
Request:
[{
"currency": "BTC",
"to": [{
"address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
"amount": 100.0,
"currency": "USD"
}]
}]
Response:
{
"invoice": {
"uid": "inv_123",
"uri": "pay:?r=https://api.anypayx.com/r/inv_123",
"status": "unpaid",
"currency": "USD",
"amount": 100.0,
"payment_options": {
"payment_options": [{
"chain": "BTC",
"currency": "BTC",
"instructions": [{
"outputs": [{
"address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
"amount": 0.0023
}]
}]
}]
}
}
}
Submit a payment for an invoice.
Request:
{
"chain": "BTC",
"currency": "BTC",
"transactions": [{
"tx": "0200000001..."
}]
}
Response:
{
"status": "success",
"message": "Payment submitted successfully"
}
Get invoice details.
Response:
{
"invoice": {
"uid": "inv_123",
"uri": "pay:?r=https://api.anypayx.com/r/inv_123",
"status": "unpaid",
"currency": "USD",
"amount": 100.0,
"payment_options": {
"payment_options": [...]
}
}
}
Error responses follow this format:
{
"status": "error",
"message": "Error description"
}
Common error scenarios:
- Invalid request format
- Resource not found
- Authentication failed
- Invalid payment data
- Server error
Most endpoints require Basic authentication:
- Username: Your API token
- Password: Empty string
Example:
Authorization: Basic YOUR_TOKEN_BASE64