{"openapi":"3.1.0","info":{"title":"Autara Data API","version":"v1","description":"Data API for Autara markets. Live endpoints are served from an in-memory cache populated via WebSocket streaming (get_all_markets_streamed), with automatic HTTP fallback (get_all_market_ids → get_market_by_id). History endpoints read from Prometheus."},"servers":[{"url":"https://api.autara.finance"}],"components":{"schemas":{"MarketSummary":{"type":"object","properties":{"id":{"type":"string","description":"Canonical market identifier (64-char hex market address).","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"market":{"type":"string","description":"Alias of `id`, kept for backward compatibility with existing clients.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"supplyApy":{"type":"number","example":0.0382},"borrowApy":{"type":"number","example":0.0721},"totalDepositsUsd":{"type":"number","example":1250000.55},"totalBorrowsUsd":{"type":"number","example":722000.15},"utilizationRate":{"type":"number","example":0.5776},"availableBorrowTokens":{"type":"number","example":12.45},"collateralFactor":{"type":"number","example":0.7},"liquidationThreshold":{"type":"number","example":0.8}},"required":["id","market","supplyApy","borrowApy","totalDepositsUsd","totalBorrowsUsd","utilizationRate","availableBorrowTokens","collateralFactor","liquidationThreshold"]},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string","example":"Invalid request"},"code":{"type":"string","enum":["BAD_REQUEST","NOT_FOUND","UPSTREAM_ERROR"],"example":"BAD_REQUEST"},"details":{"type":"object","nullable":true,"additionalProperties":{"nullable":true},"description":"Additional context for the error. May be omitted or null when no structured details are available.","example":{"reason":"invalid input"}}},"required":["error","code"]},"MarketStats":{"type":"object","properties":{"totalDepositsUsd":{"type":"number","example":5100000.75},"totalBorrowsUsd":{"type":"number","example":2800000.21},"marketsCount":{"type":"integer","example":12}},"required":["totalDepositsUsd","totalBorrowsUsd","marketsCount"]},"CurvePoint":{"type":"object","properties":{"utilization":{"type":"number","example":0.55},"apyBorrowRate":{"type":"number","example":0.0721},"apyLendingRate":{"type":"number","example":0.0382}},"required":["utilization","apyBorrowRate","apyLendingRate"]},"MarketCurve":{"type":"object","properties":{"points":{"type":"array","items":{"$ref":"#/components/schemas/CurvePoint"},"description":"Interest-rate curve points keyed by utilization."}},"required":["points"]},"MarketDetailData":{"type":"object","properties":{"marketId":{"type":"string","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"market":{"type":"object","properties":{"market":{"type":"object","properties":{"config":{"type":"object","properties":{"ltvConfig":{"type":"object","properties":{"maxLtv":{"anyOf":[{"type":"number"},{"type":"string"}]},"unhealthyLtv":{"anyOf":[{"type":"number"},{"type":"string"}]},"liquidationBonus":{"anyOf":[{"type":"number"},{"type":"string"}]}},"required":["maxLtv","unhealthyLtv"]}},"required":["ltvConfig"]},"supplyVault":{"type":"object","properties":{"mint":{"type":"array","items":{"type":"integer","minimum":0,"maximum":255}},"mintDecimals":{"anyOf":[{"type":"number"},{"type":"string"}]}},"required":["mint","mintDecimals"]},"collateralVault":{"type":"object","properties":{"mint":{"type":"array","items":{"type":"integer","minimum":0,"maximum":255}},"mintDecimals":{"anyOf":[{"type":"number"},{"type":"string"}]}},"required":["mint","mintDecimals"]}},"required":["config","supplyVault","collateralVault"]},"supplyOracle":{"type":"object","properties":{"rate":{"anyOf":[{"type":"number"},{"type":"string"},{"nullable":true}]},"confidence":{"anyOf":[{"type":"number"},{"type":"string"},{"nullable":true}]}},"required":["rate"]},"collateralOracle":{"type":"object","properties":{"rate":{"anyOf":[{"type":"number"},{"type":"string"},{"nullable":true}]},"confidence":{"anyOf":[{"type":"number"},{"type":"string"},{"nullable":true}]}},"required":["rate"]}},"required":["market","supplyOracle","collateralOracle"]},"supplyVaultSummary":{"type":"object","properties":{"totalSupply":{"anyOf":[{"type":"number"},{"type":"string"}]},"totalBorrow":{"anyOf":[{"type":"number"},{"type":"string"}]},"utilisationRate":{"anyOf":[{"type":"number"},{"type":"string"}]},"borrowInterestRate":{"anyOf":[{"type":"number"},{"type":"string"}]},"lendingInterestRate":{"anyOf":[{"type":"number"},{"type":"string"}]},"lastUpdateUnixTimestamp":{"anyOf":[{"type":"number"},{"type":"string"}]},"pendingCuratorFeeAtoms":{"anyOf":[{"type":"number"},{"type":"string"}]},"pendingProtocolFeeAtoms":{"anyOf":[{"type":"number"},{"type":"string"}]}},"required":["totalSupply","totalBorrow","utilisationRate","borrowInterestRate","lendingInterestRate"]}},"required":["marketId","market","supplyVaultSummary"]},"HistorySeriesPoint":{"type":"object","properties":{"ts":{"type":"number","example":1704067200},"value":{"type":"number","example":12345.67}},"required":["ts","value"]},"HistorySeriesResponse":{"type":"object","properties":{"source":{"type":"string","enum":["prometheus"],"example":"prometheus"},"query":{"type":"string","example":"autara_market_liquidity_usd{market_address=\"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481\",liquidity_type=\"supply\"}"},"range":{"type":"object","properties":{"start":{"type":"number","example":1704067200},"end":{"type":"number","example":1706659200},"step":{"type":"string","example":"1h"}},"required":["start","end","step"]},"series":{"type":"array","items":{"type":"object","properties":{"labels":{"type":"object","additionalProperties":{"type":"string"},"example":{"__name__":"autara_market_liquidity_usd","asset":"aut","instance":"autara-metrics:8080","job":"autara-metrics","market_address":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481","liquidity_type":"supply"}},"values":{"type":"array","items":{"$ref":"#/components/schemas/HistorySeriesPoint"}}},"required":["labels","values"]}}},"required":["source","query","range","series"]},"HealthResponse":{"type":"object","properties":{"lastPollAt":{"type":"number","nullable":true,"example":1708439490123},"cacheAgeMs":{"type":"number","nullable":true,"example":412},"stale":{"type":"boolean","example":false},"lastPollError":{"type":"string","nullable":true,"example":null}},"required":["lastPollAt","cacheAgeMs","stale","lastPollError"]}},"parameters":{}},"paths":{"/v1/markets/summary":{"get":{"tags":["Live Markets"],"summary":"Get markets summary subset","description":"Returns cache-backed market rows/cards data for markets pages. Source: in-memory cache populated by the poller.","responses":{"200":{"description":"Live cache response","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["cache"]},"asOf":{"type":"string","format":"date-time","example":"2026-02-24T10:00:00.000Z"},"data":{"type":"array","items":{"$ref":"#/components/schemas/MarketSummary"}}},"required":["source","asOf","data"]},"examples":{"live":{"summary":"Live cache response","value":{"source":"cache","asOf":"2026-02-24T10:00:00.000Z","data":[{"id":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481","market":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481","supplyApy":0.0382,"borrowApy":0.0721,"totalDepositsUsd":1250000.55,"totalBorrowsUsd":722000.15,"utilizationRate":0.5776,"availableBorrowTokens":12.45,"collateralFactor":0.7,"liquidationThreshold":0.8}]}}}}}},"502":{"description":"Upstream/cache unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/stats":{"get":{"tags":["Live Markets"],"summary":"Get aggregate market stats","description":"Returns cache-backed global market totals for top-level header stats. Source: in-memory cache populated by the poller.","responses":{"200":{"description":"Live stats response","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["cache"]},"asOf":{"type":"string","format":"date-time","example":"2026-02-24T10:00:00.000Z"},"data":{"$ref":"#/components/schemas/MarketStats"}},"required":["source","asOf","data"]},"examples":{"live":{"value":{"source":"cache","asOf":"2026-02-24T10:00:00.000Z","data":{"totalDepositsUsd":5100000.75,"totalBorrowsUsd":2800000.21,"marketsCount":12}}}}}}},"502":{"description":"Upstream/cache unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/meta":{"get":{"tags":["Live Markets"],"summary":"Get market metadata map","description":"Returns cache-backed map of market id to price/token metadata for portfolio enrichment and id mapping. Source: in-memory cache.","responses":{"200":{"description":"Metadata map","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["cache"]},"asOf":{"type":"string","format":"date-time","example":"2026-02-24T10:00:00.000Z"},"data":{"type":"object","additionalProperties":{"type":"object","properties":{"loanPrice":{"type":"number","nullable":true},"colPrice":{"type":"number","nullable":true},"loanDecimals":{"type":"number","nullable":true},"collateralDecimals":{"type":"number","nullable":true},"loanMint":{"type":"string","nullable":true},"collateralMint":{"type":"string","nullable":true}},"required":["loanPrice","colPrice","loanDecimals","collateralDecimals","loanMint","collateralMint"]}}},"required":["source","asOf","data"]}}}},"502":{"description":"Upstream/cache unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/page-data":{"get":{"tags":["Live Markets"],"summary":"Get markets page data bundle","description":"Returns cache-backed combined payload to replace separate fetches for stats and market summary in frontend pages. Source: in-memory cache.","responses":{"200":{"description":"Bundled page payload","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["cache"]},"asOf":{"type":"string","format":"date-time","example":"2026-02-24T10:00:00.000Z"},"data":{"type":"object","properties":{"stats":{"$ref":"#/components/schemas/MarketStats"},"markets":{"type":"array","items":{"$ref":"#/components/schemas/MarketSummary"}}},"required":["stats","markets"]}},"required":["source","asOf","data"]}}}},"502":{"description":"Upstream/cache unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/{id}/meta":{"get":{"tags":["Live Markets"],"summary":"Get single market metadata","description":"Returns price/token metadata for a single market by id. Source: in-memory cache.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Market metadata","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["cache"]},"asOf":{"type":"string","format":"date-time","example":"2026-02-24T10:00:00.000Z"},"data":{"type":"object","additionalProperties":{"type":"object","properties":{"loanPrice":{"type":"number","nullable":true},"colPrice":{"type":"number","nullable":true},"loanDecimals":{"type":"number","nullable":true},"collateralDecimals":{"type":"number","nullable":true},"loanMint":{"type":"string","nullable":true},"collateralMint":{"type":"string","nullable":true}},"required":["loanPrice","colPrice","loanDecimals","collateralDecimals","loanMint","collateralMint"]}}},"required":["source","asOf","data"]}}}},"404":{"description":"Market not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream/cache unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/{id}/page-data":{"get":{"tags":["Live Markets"],"summary":"Get single market page data bundle","description":"Returns stats and summary for a single market. Source: in-memory cache.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Bundled page payload","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["cache"]},"asOf":{"type":"string","format":"date-time","example":"2026-02-24T10:00:00.000Z"},"data":{"type":"object","properties":{"stats":{"$ref":"#/components/schemas/MarketStats"},"markets":{"type":"array","items":{"$ref":"#/components/schemas/MarketSummary"}}},"required":["stats","markets"]}},"required":["source","asOf","data"]}}}},"404":{"description":"Market not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream/cache unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/{id}/curve":{"get":{"tags":["Live Markets"],"summary":"Get market curve points","description":"Returns only interest-rate curve points for chart rendering. Source: in-memory cache.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Curve data","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["cache"]},"asOf":{"type":"string","format":"date-time","example":"2026-02-24T10:00:00.000Z"},"data":{"$ref":"#/components/schemas/MarketCurve"}},"required":["source","asOf","data"]}}}},"404":{"description":"Market not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream/cache unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/{id}":{"get":{"tags":["Live Markets"],"summary":"Get market detail by id","description":"Returns cache-backed market detail (excluding full curve payload) for detail page rendering. Source: in-memory cache.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Market detail","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["cache"]},"asOf":{"type":"string","format":"date-time","example":"2026-02-24T10:00:00.000Z"},"data":{"$ref":"#/components/schemas/MarketDetailData"}},"required":["source","asOf","data"]}}}},"404":{"description":"Market not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream/cache unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/history/range":{"get":{"tags":["History"],"summary":"Get available historical range","description":"Returns observed min/max timestamps from Prometheus samples. Use this to see how much history is actually available.","responses":{"200":{"description":"Observed history range","content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string","enum":["prometheus"]},"observed":{"type":"object","properties":{"start":{"type":"number","nullable":true},"end":{"type":"number","nullable":true},"startIso":{"type":"string","nullable":true},"endIso":{"type":"string","nullable":true},"savedSeconds":{"type":"number","nullable":true},"savedHours":{"type":"number","nullable":true},"query":{"type":"string"},"sampledStep":{"type":"string"}},"required":["start","end","startIso","endIso","savedSeconds","savedHours","query","sampledStep"]}},"required":["source","observed"]},"examples":{"default":{"value":{"source":"prometheus","observed":{"start":1740412800,"end":1771948800,"startIso":"2025-02-24T00:00:00.000Z","endIso":"2026-02-24T00:00:00.000Z","savedSeconds":31536000,"savedHours":8760,"query":"sum(autara_market_liquidity_usd)","sampledStep":"1h"}}}}}}}}}},"/v1/markets/{id}/history/supply":{"get":{"tags":["History"],"summary":"Get market supply USD history","description":"Returns Prometheus-backed time series for market supply USD. Source: Prometheus query_range.\n\nHistory mode semantics:\n- `start` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `end` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `step` accepts Prometheus duration strings (`1m`, `5m`, `1h`, `1d`).\n- If `end` omitted, defaults to now.\n- If `start` omitted, defaults to `end - 1 year`.\n- If `start > end`, returns HTTP 400.\n- If `start/end` + `step` would generate too many points, returns HTTP 400 with a message to reduce range or use a larger step.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","description":"Start range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string","description":"End range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"end","in":"query"},{"schema":{"type":"string","description":"Prometheus duration (for example 1m, 5m, 1h, 1d)","example":"1h"},"required":false,"name":"step","in":"query"}],"responses":{"200":{"description":"History series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistorySeriesResponse"},"examples":{"default":{"value":{"source":"prometheus","query":"autara_market_liquidity_usd{market_address=\"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481\",liquidity_type=\"supply\"}","range":{"start":1704067200,"end":1706659200,"step":"1h"},"series":[{"labels":{"__name__":"autara_market_liquidity_usd","asset":"aut","instance":"autara-metrics:8080","job":"autara-metrics","market_address":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481","liquidity_type":"supply"},"values":[{"ts":1704067200,"value":12345.67}]}]}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream Prometheus error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/{id}/history/borrow":{"get":{"tags":["History"],"summary":"Get market borrow USD history","description":"Returns Prometheus-backed time series for market borrow USD. Source: Prometheus query_range.\n\nHistory mode semantics:\n- `start` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `end` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `step` accepts Prometheus duration strings (`1m`, `5m`, `1h`, `1d`).\n- If `end` omitted, defaults to now.\n- If `start` omitted, defaults to `end - 1 year`.\n- If `start > end`, returns HTTP 400.\n- If `start/end` + `step` would generate too many points, returns HTTP 400 with a message to reduce range or use a larger step.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","description":"Start range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string","description":"End range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"end","in":"query"},{"schema":{"type":"string","description":"Prometheus duration (for example 1m, 5m, 1h, 1d)","example":"1h"},"required":false,"name":"step","in":"query"}],"responses":{"200":{"description":"History series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistorySeriesResponse"},"examples":{"default":{"value":{"source":"prometheus","query":"autara_market_liquidity_usd{market_address=\"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481\",liquidity_type=\"borrow\"}","range":{"start":1704067200,"end":1706659200,"step":"1h"},"series":[{"labels":{"__name__":"autara_market_liquidity_usd","asset":"aut","instance":"autara-metrics:8080","job":"autara-metrics","market_address":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481","liquidity_type":"borrow"},"values":[{"ts":1704067200,"value":12345.67}]}]}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream Prometheus error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/{id}/history/collateral":{"get":{"tags":["History"],"summary":"Get market collateral USD history","description":"Returns Prometheus-backed time series for market collateral USD. Source: Prometheus query_range.\n\nHistory mode semantics:\n- `start` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `end` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `step` accepts Prometheus duration strings (`1m`, `5m`, `1h`, `1d`).\n- If `end` omitted, defaults to now.\n- If `start` omitted, defaults to `end - 1 year`.\n- If `start > end`, returns HTTP 400.\n- If `start/end` + `step` would generate too many points, returns HTTP 400 with a message to reduce range or use a larger step.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","description":"Start range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string","description":"End range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"end","in":"query"},{"schema":{"type":"string","description":"Prometheus duration (for example 1m, 5m, 1h, 1d)","example":"1h"},"required":false,"name":"step","in":"query"}],"responses":{"200":{"description":"History series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistorySeriesResponse"},"examples":{"default":{"value":{"source":"prometheus","query":"autara_market_liquidity_usd{market_address=\"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481\",liquidity_type=\"collateral\"}","range":{"start":1704067200,"end":1706659200,"step":"1h"},"series":[{"labels":{"__name__":"autara_market_liquidity_usd","asset":"aut","instance":"autara-metrics:8080","job":"autara-metrics","market_address":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481","liquidity_type":"collateral"},"values":[{"ts":1704067200,"value":12345.67}]}]}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream Prometheus error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/{id}/history/utilization":{"get":{"tags":["History"],"summary":"Get market utilization history","description":"Returns Prometheus-backed time series for market utilization rate. Source: Prometheus query_range.\n\nHistory mode semantics:\n- `start` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `end` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `step` accepts Prometheus duration strings (`1m`, `5m`, `1h`, `1d`).\n- If `end` omitted, defaults to now.\n- If `start` omitted, defaults to `end - 1 year`.\n- If `start > end`, returns HTTP 400.\n- If `start/end` + `step` would generate too many points, returns HTTP 400 with a message to reduce range or use a larger step.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","description":"Start range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string","description":"End range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"end","in":"query"},{"schema":{"type":"string","description":"Prometheus duration (for example 1m, 5m, 1h, 1d)","example":"1h"},"required":false,"name":"step","in":"query"}],"responses":{"200":{"description":"History series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistorySeriesResponse"},"examples":{"default":{"value":{"source":"prometheus","query":"autara_market_utilization_rate{market_address=\"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481\"}","range":{"start":1704067200,"end":1706659200,"step":"1h"},"series":[{"labels":{"__name__":"autara_market_utilization_rate","asset":"aut","instance":"autara-metrics:8080","job":"autara-metrics","market_address":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"values":[{"ts":1704067200,"value":12345.67}]}]}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream Prometheus error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/markets/{id}/history/rates":{"get":{"tags":["History"],"summary":"Get market rates history","description":"Returns Prometheus-backed time series for market borrow and lending rates. Source: Prometheus query_range.\n\nHistory mode semantics:\n- `start` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `end` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `step` accepts Prometheus duration strings (`1m`, `5m`, `1h`, `1d`).\n- If `end` omitted, defaults to now.\n- If `start` omitted, defaults to `end - 1 year`.\n- If `start > end`, returns HTTP 400.\n- If `start/end` + `step` would generate too many points, returns HTTP 400 with a message to reduce range or use a larger step.","parameters":[{"schema":{"type":"string","description":"64-char hex market address.","example":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","description":"Start range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string","description":"End range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"end","in":"query"},{"schema":{"type":"string","description":"Prometheus duration (for example 1m, 5m, 1h, 1d)","example":"1h"},"required":false,"name":"step","in":"query"}],"responses":{"200":{"description":"Rates history series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistorySeriesResponse"},"examples":{"default":{"value":{"source":"prometheus","query":"autara_market_borrow_rate{market_address=\"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481\"}; autara_market_lending_rate{market_address=\"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481\"}","range":{"start":1704067200,"end":1706659200,"step":"1h"},"series":[{"labels":{"metric":"borrow_rate","__name__":"autara_market_borrow_rate","asset":"aut","instance":"autara-metrics:8080","job":"autara-metrics","market_address":"dde89af6942d055c5fc7c91f948a23fa4ad44535c093d6e0054a2fdac550a481"},"values":[{"ts":1704067200,"value":0.071}]}]}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream Prometheus error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/positions/{user}/history/ltv":{"get":{"tags":["History"],"summary":"Get user LTV history","description":"Returns Prometheus-backed time series for user position LTV. Source: Prometheus query_range.\n\nHistory mode semantics:\n- `start` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `end` accepts `min`, `max`, unix seconds, unix milliseconds, OR ISO8601.\n- `step` accepts Prometheus duration strings (`1m`, `5m`, `1h`, `1d`).\n- If `end` omitted, defaults to now.\n- If `start` omitted, defaults to `end - 1 year`.\n- If `start > end`, returns HTTP 400.\n- If `start/end` + `step` would generate too many points, returns HTTP 400 with a message to reduce range or use a larger step.","parameters":[{"schema":{"type":"string","description":"64-char hex user pubkey.","example":"f6cc41111df5410aff54242c92b7a16c59d3968e9adfa3a1a9ffea3308e34f39"},"required":true,"name":"user","in":"path"},{"schema":{"type":"string","description":"Start range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string","description":"End range: min|max|unix seconds|unix milliseconds|ISO8601"},"required":false,"name":"end","in":"query"},{"schema":{"type":"string","description":"Prometheus duration (for example 1m, 5m, 1h, 1d)","example":"1h"},"required":false,"name":"step","in":"query"}],"responses":{"200":{"description":"User LTV series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistorySeriesResponse"},"examples":{"default":{"value":{"source":"prometheus","query":"autara_position_ltv{user_address=\"f6cc41111df5410aff54242c92b7a16c59d3968e9adfa3a1a9ffea3308e34f39\"}","range":{"start":1704067200,"end":1706659200,"step":"1d"},"series":[{"labels":{"__name__":"autara_position_ltv","asset":"aut","instance":"autara-metrics:8080","job":"autara-metrics","user_address":"f6cc41111df5410aff54242c92b7a16c59d3968e9adfa3a1a9ffea3308e34f39"},"values":[{"ts":1704067200,"value":0.42}]}]}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream Prometheus error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/users":{"get":{"tags":["User"],"summary":"List all unique users","description":"Returns every unique user pubkey that has at least one supply or borrow position on Autara. Source: autara-server JSON-RPC `get_all_users`.","responses":{"200":{"description":"List of unique user pubkeys","content":{"application/json":{"schema":{"type":"object","properties":{"users":{"type":"array","items":{"type":"string"}},"count":{"type":"number"}},"required":["users","count"]},"examples":{"default":{"value":{"users":["f6cc41111df5410aff54242c92b7a16c59d3968e9adfa3a1a9ffea3308e34f39"],"count":1}}}}}},"502":{"description":"Upstream RPC error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"upstreamError":{"value":{"error":"RPC get_all_users failed: unknown error","code":"UPSTREAM_ERROR","details":{"method":"get_all_users"}}}}}}}}}},"/v1/positions/{user}":{"get":{"tags":["User"],"summary":"Get user positions","description":"Returns user positions from autara RPC (direct call, not from market cache). Source: autara-server JSON-RPC. `user` must be a 64-char hex pubkey.","parameters":[{"schema":{"type":"string","description":"64-char hex user pubkey.","example":"f6cc41111df5410aff54242c92b7a16c59d3968e9adfa3a1a9ffea3308e34f39"},"required":true,"name":"user","in":"path"}],"responses":{"200":{"description":"User positions","content":{"application/json":{"schema":{"type":"object","properties":{"positions":{"type":"object","properties":{"supplyPositions":{"type":"array","items":{"type":"object","properties":{"market":{"type":"string"},"amount":{"anyOf":[{"type":"number"},{"type":"string"}]},"uiAmount":{"anyOf":[{"type":"number"},{"type":"string"}]}}}},"borrowPositions":{"type":"array","items":{"type":"object","properties":{"market":{"type":"string"},"amount":{"anyOf":[{"type":"number"},{"type":"string"}]},"uiAmount":{"anyOf":[{"type":"number"},{"type":"string"}]}}}}},"required":["supplyPositions","borrowPositions"]}},"required":["positions"]},"examples":{"default":{"value":{"positions":{"supplyPositions":[],"borrowPositions":[]}}}}}}},"400":{"description":"Invalid user pubkey format","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"invalidUser":{"value":{"error":"Invalid user pubkey format. Use 64-char hex pubkey.","code":"BAD_REQUEST","details":{"user":"arch1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"}}}}}}},"502":{"description":"Upstream RPC error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"upstreamError":{"value":{"error":"RPC get_user_positions failed: Invalid params","code":"UPSTREAM_ERROR","details":{"method":"get_user_positions"}}}}}}}}}},"/v1/balances/{user}":{"get":{"tags":["User"],"summary":"Get user balances","description":"Returns user balances from autara RPC (direct call, not from market cache). Source: autara-server JSON-RPC. `user` must be a 64-char hex pubkey.","parameters":[{"schema":{"type":"string","description":"64-char hex user pubkey.","example":"f6cc41111df5410aff54242c92b7a16c59d3968e9adfa3a1a9ffea3308e34f39"},"required":true,"name":"user","in":"path"}],"responses":{"200":{"description":"User balances","content":{"application/json":{"schema":{"type":"object","properties":{"balances":{"type":"array","items":{"type":"object","properties":{"mint":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"integer","minimum":0,"maximum":255}}]},"amount":{"anyOf":[{"type":"number"},{"type":"string"}]},"uiAmount":{"anyOf":[{"type":"number"},{"type":"string"}]}},"required":["mint","amount","uiAmount"]}}},"required":["balances"]},"examples":{"default":{"value":{"balances":[{"mint":[168,15,167,158],"amount":50000000000,"uiAmount":"50000"}]}}}}}},"400":{"description":"Invalid user pubkey format","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"invalidUser":{"value":{"error":"Invalid user pubkey format. Use 64-char hex pubkey.","code":"BAD_REQUEST","details":{"user":"arch1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"}}}}}}},"502":{"description":"Upstream RPC error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"upstreamError":{"value":{"error":"RPC get_user_balances failed: Invalid params","code":"UPSTREAM_ERROR","details":{"method":"get_user_balances"}}}}}}}}}},"/v1/health":{"get":{"tags":["Health"],"summary":"Get cache poller health","description":"Returns cache freshness and poll status for monitoring (`stale` indicates poll failure or aged cache).","responses":{"200":{"description":"Health payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"examples":{"default":{"value":{"lastPollAt":1708439490123,"cacheAgeMs":412,"stale":false,"lastPollError":null}}}}}}}}}}}