Launch App

HTTP API

Public read endpoints served by the Longbow web application. All responses are returned as JSON payloads. No authentication or API keys are required.

Endpoints Registry

EndpointDescriptionCache Policy
GET /api/quote?symbol=TSLAfetches the off-chain stock quote (Finnhub → Alpha Vantage → mock fallback)15 seconds
GET /api/marketsall tokens: on-chain vs real price, premium/discount calculation, and 24h changeno-cache
GET /api/tokensfetches the token registry configuration + protocol addresses for the active chainno-cache
GET /api/reserves?symbol=TSLAqueries Uniswap V2 token/USDG reserves directly via factory.getPair and getReservesno-cache
GET /api/orders?status=activeactive order mirror database (called by keepers to poll execution candidates)no-cache

GET /api/quote

200 response
{
  "symbol": "TSLA",
  "price": 268.45,
  "marketOpen": true,
  "source": "finnhub",        // "finnhub" | "alphavantage" | "mock"
  "ts": 1783102938123
}

Query Parameters: symbol (e.g. TSLA, NVDA).

Errors: 400 missing symbol, 404 unknown symbol. The server caches each symbol for 15 seconds to respect Finnhub's free-tier limit (60 req/min). To bypass public caching limits, supply your own developer API key in the server configuration via FINNHUB_API_KEY.

GET /api/markets

200 response
{
  "mode": "live",
  "rows": [
    {
      "symbol": "TSLA",
      "name": "Tesla",
      "kind": "stock",
      "address": "0x322F…3b2d",
      "real": 268.45,          // off-chain quote (USD)
      "onchain": 268.97,       // Chainlink feed (USD)
      "premiumPct": 0.19,      // + premium / − discount
      "change24hPct": 1.24,
      "marketOpen": true,
      "history": [267.1, 268.2, 268.97] // sparkline samples, 24h
    }
  ]
}

premiumPct is signed: positive values represent on-chain swaps trading rich compared to traditional stock quotes; negative values represent a discount. Note that off-hours the on-chain oracles may freeze; compare marketOpen flags before committing arbitrage trades.

GET /api/tokens

200 response
{
  "chainId": 4663,
  "mode": "live",
  "addresses": { "uniswapV2Router02": "0x89e5…9eba", "uniswapV2Factory": "0x8bce..." },
  "tokens": [
    { "symbol": "TSLA", "name": "Tesla", "kind": "stock",
      "decimals": 18, "address": "0x322F…3b2d", "chainlinkFeed": "0x…" }
  ]
}

GET /api/reserves

200 response
{
  "symbol": "TSLA",
  "pairAddress": "0x51296baE01...",
  "reserveStock": "1250000000000000000000", // 1,250 TSLA (18 decimals)
  "reserveUsdg": "335000000000",             // 335,000 USDG (6 decimals)
  "price": 268.00,                           // ratio price of reserveUsdg/reserveStock
  "ts": 1783102938555
}

Query Parameters: symbol (e.g. TSLA).

Returns raw reserves from the Uniswap V2 pool pair. Useful for calculating off-chain slippage and price impact checks dynamically before submitting transaction orders.

GET /api/orders

200 response
{
  "mode": "live",
  "orders": [
    {
      "id": "42",
      "owner": "0x9832...",
      "tokenIn": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",  // USDG
      "tokenOut": "0x322F0929c4625eD5bAd873c95208D54E1c003b2d", // TSLA
      "priceFeed": "0x12f1...",                                 // Chainlink TSLA feed
      "amountIn": "1500000000",                                 // 1,500 USDG (6 decimals)
      "minAmountOut": "5500000000000000000",                    // 5.5 TSLA (18 decimals)
      "triggerPrice": "26200000000",                            // $262.00 (8 decimals)
      "triggerDir": 0,                                          // 0 BELOW, 1 ABOVE
      "orderType": 0,                                           // 0 LIMIT, 1 DCA
      "interval": "0",
      "remainingRuns": 1,
      "active": true
    }
  ]
}

Query Parameters: status (active, executed, cancelled).

Keeper nodes use this endpoint to poll candidate orders. Values like amountIn,minAmountOut, and triggerPrice are returned as string-encoded big numbers respecting decimals.