AI Agent Integration

Automate auction creation, bidding, and settlement with AI agents

Overview

The SNS Auctions API enables AI agents to fully automate auction workflows. Agents can:

  • Monitor market conditions and create auctions programmatically
  • Place bids based on custom strategies and risk parameters
  • Trigger auction settlement once auctions have ended
  • Track portfolio performance and historical data
  • Receive real-time webhooks for market events

Agent Types & Use Cases

Market Maker Agent

Creates auctions for premium domains and adjusts pricing based on demand signals and historical sales data.

Snipe Fighter Agent

Monitors auctions nearing their end time and automatically places counter-bids when snipe attempts are detected.

Arbitrage Agent

Identifies price discrepancies across platforms and automatically buys low/sells high to profit from spreads.

Setting Up Agent API Keys

Create dedicated API keys for each agent with specific permissions:

Create Agent API Key
curl -X POST https://api.snsauctions.xyz/api/v1/keys/create \
  -H "Content-Type: application/json" \
  -d '{
    "name": "market_maker_agent",
    "type": "agent",
    "walletAddress": "YourSolanaWalletAddress"
  }'
name: Description of the agent
type: Set to "agent" (vs "developer" for apps)
walletAddress: Solana wallet that will execute transactions

How Transactions Work

For auction creation and bidding, the API builds and returns a base64-encoded unsigned Solana transaction. Your agent signs it with its own wallet keypair and broadcasts it directly to any Solana RPC endpoint. Settlement is the exception — the server signs and broadcasts that on your behalf using the platform keeper.

Flow summary
1. Agent calls API → receives transaction (base64 unsigned tx)
2. Agent signs with its Solana keypair
3. Agent broadcasts signed tx to RPC
4. On-chain program executes; no platform custody of funds

Example: Market Maker Agent

Create an agent that monitors inventory and automatically lists domains for sale:

Python Example
import base64
import os
import time

import requests
from solders.keypair import Keypair
from solders.transaction import Transaction
from solana.rpc.api import Client

API_KEY = os.environ["SNS_API_KEY"]           # sk_live_...
WALLET_KEYPAIR = Keypair.from_base58_string(os.environ["AGENT_PRIVATE_KEY"])
RPC_URL = os.environ.get("SOLANA_RPC_URL", "https://api.mainnet-beta.solana.com")

API_URL = "https://snsauctions.xyz/api/v1"
HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"}
rpc = Client(RPC_URL)


def get_market_conditions():
    """Fetch active auctions to gauge current prices."""
    resp = requests.get(
        f"{API_URL}/auctions",
        params={"status": "active", "pageSize": 100},
        headers=HEADERS,
    )
    resp.raise_for_status()
    return resp.json()


def calculate_asking_price(market_data):
    """Simple strategy: average current price + 20% markup."""
    auctions = market_data["data"]["auctions"]
    if not auctions:
        return 1.0
    avg = sum(a["currentPrice"] for a in auctions) / len(auctions)
    return round(avg * 1.2, 4)


def sign_and_broadcast(transaction_b64: str) -> str:
    """Sign a base64 unsigned transaction and broadcast it."""
    raw = base64.b64decode(transaction_b64)
    tx = Transaction.from_bytes(raw)
    tx.sign([WALLET_KEYPAIR])
    result = rpc.send_raw_transaction(bytes(tx))
    return str(result.value)  # transaction signature


def create_auction(domain: str, price: float) -> dict:
    """Ask the API to build a create_auction transaction, then sign & broadcast."""
    resp = requests.post(
        f"{API_URL}/auctions/create",
        json={
            "domainNames": [domain],
            "type": "standard",
            "startingPrice": price,
            "minBidIncrement": 0.1,
            "durationHours": 24,
            "snipeProtectionEnabled": True,
        },
        headers=HEADERS,
    )
    resp.raise_for_status()
    data = resp.json()

    if not data.get("success"):
        raise RuntimeError(f"API error: {data.get('error')}")

    tx_sig = sign_and_broadcast(data["data"]["transaction"])
    return {"auctionId": data["data"]["auctionId"], "txSig": tx_sig}


# ── Main agent loop ────────────────────────────────────────────────────────
domains = ["premium.sol", "rare.sol", "short.sol"]

for domain in domains:
    market = get_market_conditions()
    price = calculate_asking_price(market)
    result = create_auction(domain, price)
    print(f"Listed {domain} at {price} SOL | auction={result['auctionId']} tx={result['txSig']}")
    time.sleep(1)

Example: Placing a Bid

The same sign-and-broadcast pattern applies to bids:

Python Example
def place_bid(auction_id: str, bid_amount_sol: float) -> dict:
    """Ask the API to build a place_bid transaction, then sign & broadcast."""
    resp = requests.post(
        f"{API_URL}/auctions/{auction_id}/bid",
        json={"auctionId": auction_id, "bidAmount": bid_amount_sol},
        headers=HEADERS,
    )
    resp.raise_for_status()
    data = resp.json()

    if not data.get("success"):
        raise RuntimeError(f"API error: {data.get('error')}")

    tx_sig = sign_and_broadcast(data["data"]["transaction"])
    return {
        "txSig": tx_sig,
        "nextMinimumBid": data["data"]["nextMinimumBid"],
    }


# Example usage
result = place_bid("AuctionPDAbase58...", 2.5)
print(f"Bid placed | tx={result['txSig']} | next min={result['nextMinimumBid']} SOL")

Real-time Event Webhooks

Subscribe to webhooks to receive real-time notifications instead of polling. Use the webhook management endpoints to create and manage subscriptions:

Create Webhook Subscription
POST /api/v1/webhooks/create
X-API-Key: sk_live_your_key

{
  "url": "https://your-agent.example.com/webhooks/auctions",
  "events": ["auction.bid", "auction.settled", "auction.created"]
}

Your webhook endpoint will receive POST requests with this payload format:

Webhook Payload
{
  "event": "auction.bid",
  "auctionId": "auction_123",
  "domain": "example.sol",
  "data": {
    "bidder": "7B4X5wUohEzB8UZjfAvaxS1huNY6q5p5XqvCH7r6T1Hj",
    "bidAmount": 2.5
  },
  "timestamp": 1234567890,
  "id": "evt_unique_id"
}

See /api/webhooks documentation for full webhook management API reference.

Best Practices

🔐 Security

  • Never hardcode API keys in agent code
  • Use environment variables or secret management
  • Rotate API keys regularly
  • Use separate keys per service to reduce blast radius

⚡ Performance

  • Use webhooks instead of polling when possible
  • Batch requests to stay within rate limits
  • Cache market data to reduce API calls
  • Implement exponential backoff for retries

🎯 Risk Management

  • Start with small bid amounts to test strategy
  • Implement daily loss limits
  • Monitor agent performance metrics
  • Have manual override capabilities

© 2026 SNSAuctions.xyz. Built on Solana.