{"uid":"cap_uiG5-M1zXbbj0YETRWG51","slug":"perpgap-historical-price-gap-api-df0e1846","name":"PerpGap Historical Price Gap API","description":"Use when an agent needs to backtest or chart how a stock perp's premium/discount and funding evolved, including weekends and holidays when the stock is shut. One ticker: trade.xyz perp mark/oracle vs stock and xStock, basis, funding, OI, Aster/Lighter/OKX cross-venue gaps; 30-minute snapshots plus ~60d backfill, up to 90 days per call. Bad params return 400/404 before any charge. Errors: 400, 402, 404, 502. Data, not advice.","url":"https://perp-gap-api.perpgap.workers.dev/history?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["ticker"],"properties":{"to":{"type":"string","format":"date-time","description":"Optional ISO 8601 end (default: now)."},"from":{"type":"string","format":"date-time","description":"Optional ISO 8601 start (default: 7 days before 'to')."},"ticker":{"type":"string","pattern":"^[A-Za-z0-9.]{1,12}$","examples":["NVDA"],"description":"Stock ticker, case-insensitive (free list: GET /catalog)."},"interval":{"enum":["30m","1h","4h","1d"],"type":"string","default":"1h","description":"Optional bucket size."}},"additionalProperties":false}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"to":{"type":"string"},"from":{"type":"string"},"rows":{"type":"array"},"count":{"type":"number"},"ticker":{"type":"string"},"sources":{"type":"object"},"interval":{"type":"string"},"disclaimer":{"type":"string"}},"description":"Error responses are JSON {error: string, hint?: string}. 400 bad params (never charged); 402 payment required; 404 ticker/market not listed (checked before settlement, never charged); 502 upstream error. Full field docs: /openapi.json."}}}}},"responseSchema":{"type":"json","example":{"to":"2026-10-29T15:40:38.943Z","from":"2026-10-22T15:40:38.943Z","rows":[{"ts":1793287806,"time":"2026-10-29T15:30:06.000Z","source":"snapshot","ticker":"NVDA","perp_mark":214.07,"perp_oracle":214.01}],"count":168,"ticker":"NVDA","sources":{"backfill":"Hyperliquid candles/funding backfill (stock-reference fields null)"},"interval":"1h","disclaimer":"Data, not financial advice."}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_TAjGQfRTl6Ek8dLGFHhXX","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Returns historical time-series data on price gaps between stock perpetual futures (trade.xyz, Aster, Lighter) and reference stock prices or Solana xStocks, including funding rates, OI, and basis metrics","exampleAgentPrompt":"Pull the hourly price gap history for TSLA between October 7 and October 14, 2026, including funding rates, open interest, and how the perp mark on trade.xyz compared to the real stock price and xStock price.","exampleUseCases":[{"title":"Weekly arbitrage opportunity review","prompt":"Show me the hourly gap history for TSLA perps versus the real stock price and xStock from last Monday through Sunday, so I can see when the biggest arbitrage windows opened up."},{"title":"Funding rate trend analysis","prompt":"Pull the daily funding rate history for NVDA perps over the past 30 days across trade.xyz, Aster, and Lighter — I want to see the annualized rates and how they've trended."},{"title":"Exchange spread comparison over time","prompt":"Give me a week of hourly data on the price spread between Aster and trade.xyz for AAPL perps, including the max mark spread and basis vs oracle for each snapshot."}],"resultDescription":"Returns a JSON array of time-series rows for the requested ticker and date range. Each row includes timestamps, perp mark prices from trade.xyz/Aster/Lighter, reference stock price, xStock price, hourly and annualized funding rates, open interest in USD, and percentage gap metrics between each exchange pair and versus the reference stock. Also returns count, ticker, interval, and a disclaimer.","failureModes":["Invalid or unsupported ticker symbol returns an error or empty rows","Date range too wide may result in truncated or paginated data","Payment failure (x402) if USDC balance is insufficient on Base or Solana","Missing required fields (ticker, from, to) returns a validation error","Interval value not supported returns an error","Data unavailable for non-market hours may return sparse rows"],"whenToPreferThis":"Use this endpoint when you need time-series historical data on stock perpetual price gaps across decentralized exchanges (trade.xyz, Aster, Lighter) versus real stock prices or Solana xStocks. Prefer this over real-time snapshot endpoints when trend analysis, backtesting, or funding rate history over a date range is the goal. Ideal for arbitrage research, basis trading analysis, and on-chain synthetic stock monitoring across multiple DeFi venues.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-28T06:35:00.834Z","isFirstParty":false,"canonicalSlug":"perpgap-historical-price-gap-api-df0e1846"}