Skip to main content

Quickstart

Get started with the 0xMeta AI API in just a few minutes.
You’ll connect your wallet, obtain a payment proof, and query live market intelligence data.

Get Started in Three Steps

1

Get Payment Proof

Connect your wallet and approve a small payment to receive your payment proof via x402.
# Visit any endpoint in your browser and you'll be prompted to pay.
https://api.0xmeta.ai/v1/markets/trends
2

Make Your First Request

Use the payment proof to call any endpoint.
curl -X GET "https://api.0xmeta.ai/v1/markets/trends?limit=10&timeframe=24h" \
  -H "X-Payment-Proof: YOUR_PAYMENT_PROOF"
3

Handle the Response

Process the market intelligence data:
Response Example
{
  "success": true,
  "timeframe": "24h",
  "trends": {
    "trending_categories": [
      {
        "category": "defi",
        "count": 45,
        "description": "Decentralized finance protocols"
      },
      {
        "category": "ai_agents",
        "count": 32,
        "description": "Autonomous AI agent ecosystem"
      }
    ],
    "trending_narratives": [
      {
        "narrative_id": "defi_yields_rising",
        "item_count": 15,
        "primary_tokens": ["$AAVE", "$CRV", "$CVX"],
        "sample_signal": "DeFi yields surge as..."
      }
    ],
    "recent_items": [
      {
        "signal": "Breaking: Major DeFi protocol...",
        "sentiment": "bullish",
        "tokens": ["$AAVE"],
        "timestamp": 1730566890.0
      }
    ]
  },
  "payer": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}

Complete Examples

import requests
from web3 import Web3

API_BASE_URL = "https://api.0xmeta.ai"
PAYMENT_PROOF = "YOUR_PAYMENT_PROOF_HERE"

def get_market_trends(limit=10, timeframe="24h"):
    response = requests.get(
        f"{API_BASE_URL}/v1/markets/trends",
        headers={"X-Payment-Proof": PAYMENT_PROOF},
        params={"limit": limit, "timeframe": timeframe}
    )
    if response.status_code == 200:
        return response.json()["trends"]
    elif response.status_code == 402:
        print("Payment required!")
    else:
        print(f"Error: {response.status_code}")

if __name__ == "__main__":
    trends = get_market_trends()
    if trends:
        print("Top trending categories:")
        for cat in trends["trending_categories"][:5]:
            print(f"  - {cat['category']}: {cat['count']} mentions")
const API_BASE_URL = "https://api.0xmeta.ai";
const PAYMENT_PROOF = "YOUR_PAYMENT_PROOF_HERE";

async function getMarketTrends(limit = 10, timeframe = "24h") {
  const response = await fetch(
    `${API_BASE_URL}/v1/markets/trends?limit=${limit}&timeframe=${timeframe}`,
    { headers: { "X-Payment-Proof": PAYMENT_PROOF } }
  );

  if (response.status === 200) {
    const data = await response.json();
    return data.trends;
  } else if (response.status === 402) {
    console.error("Payment required!");
  } else {
    console.error(`Error: ${response.status}`);
  }
}

(async () => {
  const trends = await getMarketTrends();
  if (trends) {
    console.log("Top trending categories:");
    trends.trending_categories.slice(0, 5).forEach((cat) => {
      console.log(`  - ${cat.category}: ${cat.count} mentions`);
    });
  }
})();
interface MarketTrends {
  success: boolean;
  timeframe: string;
  trends: {
    trending_categories: {
      category: string;
      count: number;
      description: string;
    }[];
    trending_narratives: {
      narrative_id: string;
      item_count: number;
      primary_tokens: string[];
      sample_signal: string;
    }[];
    recent_items: any[];
  };
  payer: string;
}

async function getMarketTrends(
  limit = 10,
  timeframe: "1h" | "6h" | "24h" | "7d" = "24h"
): Promise<MarketTrends> {
  const response = await fetch(
    `https://api.0xmeta.ai/v1/markets/trends?limit=${limit}&timeframe=${timeframe}`,
    {
      headers: { "X-Payment-Proof": process.env.PAYMENT_PROOF! },
    }
  );

  if (!response.ok) {
    throw new Error(`HTTP ${response.status}`);
  }

  return response.json() as Promise<MarketTrends>;
}

Error Handling

try:
    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        data = response.json()
    elif response.status_code == 402:
        print("Payment required — get new payment proof")
    elif response.status_code == 429:
        print("Rate limited — wait and retry")
    elif response.status_code == 500:
        print("Server error — retry later")
    else:
        print(f"Unexpected error: {response.status_code}")
except requests.exceptions.Timeout:
    print("Request timeout — retry")
except requests.exceptions.ConnectionError:
    print("Connection error — check internet")

Best Practices

Cache Locally

Cache responses for 5-10 minutes to avoid duplicate payments

Handle 402 Errors

Always handle payment required responses gracefully

Use Timeouts

Set request timeouts (5-10 seconds recommended)

Retry Logic

Implement exponential backoff for retries

Next Steps

Tip: Start with the /markets/trends endpoint - it’s the most popular and gives you a great overview of the market!