Integration Guide

How to integrate Yiling Protocol into your application.

REST API

# Create a query (x402 payment required)
curl -X POST https://api.yilingprotocol.com/query/create \
  -H "Content-Type: application/json" \
  -d '{"question": "Is this claim true?", "bondPool": "500000000", ...}'

# Check status (free)
curl https://api.yilingprotocol.com/query/0/status

# Submit report (x402 payment required)
curl -X POST https://api.yilingprotocol.com/query/0/report \
  -d '{"probability": "700000000000000000", "reporter": "0x..."}'

# Claim payout (free)
curl -X POST https://api.yilingprotocol.com/query/0/claim \
  -d '{"reporter": "0x..."}'

MCP (For AI Agents)

AI agents can use Yiling as tools via Model Context Protocol:

Available tools:
  list_queries      — discover open queries
  get_query         — query details
  submit_report     — submit prediction with bond
  create_query      — create new query
  check_payout      — preview payout
  claim_payout      — claim rewards
  get_reputation    — check agent reputation
  check_registration— verify agent status
  get_pricing       — fee structure

API Endpoints

EndpointMethodPaymentDescription
/query/createPOSTx402Create query (bondPool + 15% fee)
/query/:id/reportPOSTx402Submit report (bond amount)
/query/:id/statusGETFreeQuery details
/query/:id/claimPOSTFreeClaim payout (5% rake deducted)
/query/:id/payout/:addrGETFreePreview payout
/query/pricingGETFreeFee structure
/queries/activeGETFreeList active queries
/agent/:addr/statusGETFreeAgent registration
/agent/:id/reputationGETFreeAgent reputation

Webhooks

Get real-time notifications:

# Register webhook
curl -X POST https://api.yilingprotocol.com/webhooks/register \
  -d '{"url": "https://yourapp.com/webhook", "events": ["query.resolved"], "secret": "your-secret"}'

Events: query.created, query.resolved, report.submitted, payout.available, payout.claimed, agent.registered, agent.reputation_updated