mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-30 19:37:29 +02:00
* feat: convert 52 API endpoints from POST to GET for edge caching Convert all cacheable sebuf RPC endpoints to HTTP GET with query/path parameters, enabling CDN edge caching to reduce costs. Flatten nested request types (TimeRange, PaginationRequest, BoundingBox) into scalar query params. Add path params for resource lookups (GetFredSeries, GetHumanitarianSummary, GetCountryStockIndex, GetCountryIntelBrief, GetAircraftDetails). Rewrite router with hybrid static/dynamic matching for path param support. Kept as POST: SummarizeArticle, ClassifyEvent, RecordBaselineSnapshot, GetAircraftDetailsBatch, RegisterInterest. Generated with sebuf v0.9.0 (protoc-gen-ts-client, protoc-gen-ts-server). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add rate_limited field to market response protos The rateLimited field was hand-patched into generated files on main but never declared in the proto definitions. Regenerating wiped it out, breaking the build. Now properly defined in both ListEtfFlowsResponse and ListMarketQuotesResponse protos. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: remove accidentally committed .planning files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
662 lines
27 KiB
YAML
662 lines
27 KiB
YAML
openapi: 3.1.0
|
|
info:
|
|
title: MarketService API
|
|
version: 1.0.0
|
|
paths:
|
|
/api/market/v1/list-market-quotes:
|
|
get:
|
|
tags:
|
|
- MarketService
|
|
summary: ListMarketQuotes
|
|
description: ListMarketQuotes retrieves stock and index quotes.
|
|
operationId: ListMarketQuotes
|
|
parameters:
|
|
- name: symbols
|
|
in: query
|
|
description: Ticker symbols to retrieve (e.g., ["AAPL", "^GSPC"]). Empty returns defaults.
|
|
required: false
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: Successful response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ListMarketQuotesResponse'
|
|
"400":
|
|
description: Validation error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ValidationError'
|
|
default:
|
|
description: Error response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
/api/market/v1/list-crypto-quotes:
|
|
get:
|
|
tags:
|
|
- MarketService
|
|
summary: ListCryptoQuotes
|
|
description: ListCryptoQuotes retrieves cryptocurrency quotes from CoinGecko.
|
|
operationId: ListCryptoQuotes
|
|
parameters:
|
|
- name: ids
|
|
in: query
|
|
description: Cryptocurrency IDs to retrieve (CoinGecko IDs). Empty returns defaults.
|
|
required: false
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: Successful response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ListCryptoQuotesResponse'
|
|
"400":
|
|
description: Validation error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ValidationError'
|
|
default:
|
|
description: Error response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
/api/market/v1/list-commodity-quotes:
|
|
get:
|
|
tags:
|
|
- MarketService
|
|
summary: ListCommodityQuotes
|
|
description: ListCommodityQuotes retrieves commodity price quotes from Yahoo Finance.
|
|
operationId: ListCommodityQuotes
|
|
parameters:
|
|
- name: symbols
|
|
in: query
|
|
description: Commodity symbols to retrieve (Yahoo symbols). Empty returns defaults.
|
|
required: false
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: Successful response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ListCommodityQuotesResponse'
|
|
"400":
|
|
description: Validation error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ValidationError'
|
|
default:
|
|
description: Error response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
/api/market/v1/get-sector-summary:
|
|
get:
|
|
tags:
|
|
- MarketService
|
|
summary: GetSectorSummary
|
|
description: GetSectorSummary retrieves market sector performance data from Finnhub.
|
|
operationId: GetSectorSummary
|
|
parameters:
|
|
- name: period
|
|
in: query
|
|
description: Time period for performance calculation (e.g., "1d", "1w", "1m"). Defaults to "1d".
|
|
required: false
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: Successful response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/GetSectorSummaryResponse'
|
|
"400":
|
|
description: Validation error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ValidationError'
|
|
default:
|
|
description: Error response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
/api/market/v1/list-stablecoin-markets:
|
|
get:
|
|
tags:
|
|
- MarketService
|
|
summary: ListStablecoinMarkets
|
|
description: ListStablecoinMarkets retrieves stablecoin peg health and market data from CoinGecko.
|
|
operationId: ListStablecoinMarkets
|
|
parameters:
|
|
- name: coins
|
|
in: query
|
|
description: CoinGecko IDs to retrieve (e.g. "tether,usd-coin"). Empty returns defaults.
|
|
required: false
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: Successful response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ListStablecoinMarketsResponse'
|
|
"400":
|
|
description: Validation error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ValidationError'
|
|
default:
|
|
description: Error response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
/api/market/v1/list-etf-flows:
|
|
get:
|
|
tags:
|
|
- MarketService
|
|
summary: ListEtfFlows
|
|
description: ListEtfFlows retrieves BTC spot ETF flow estimates from Yahoo Finance.
|
|
operationId: ListEtfFlows
|
|
responses:
|
|
"200":
|
|
description: Successful response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ListEtfFlowsResponse'
|
|
"400":
|
|
description: Validation error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ValidationError'
|
|
default:
|
|
description: Error response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
/api/market/v1/get-country-stock-index/{country_code}:
|
|
get:
|
|
tags:
|
|
- MarketService
|
|
summary: GetCountryStockIndex
|
|
description: GetCountryStockIndex retrieves the primary stock index for a country from Yahoo Finance.
|
|
operationId: GetCountryStockIndex
|
|
parameters:
|
|
- name: country_code
|
|
in: path
|
|
description: ISO 3166-1 alpha-2 country code (e.g., "US", "GB", "JP").
|
|
required: true
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: Successful response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/GetCountryStockIndexResponse'
|
|
"400":
|
|
description: Validation error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ValidationError'
|
|
default:
|
|
description: Error response
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
components:
|
|
schemas:
|
|
Error:
|
|
type: object
|
|
properties:
|
|
message:
|
|
type: string
|
|
description: Error message (e.g., 'user not found', 'database connection failed')
|
|
description: Error is returned when a handler encounters an error. It contains a simple error message that the developer can customize.
|
|
FieldViolation:
|
|
type: object
|
|
properties:
|
|
field:
|
|
type: string
|
|
description: The field path that failed validation (e.g., 'user.email' for nested fields). For header validation, this will be the header name (e.g., 'X-API-Key')
|
|
description:
|
|
type: string
|
|
description: Human-readable description of the validation violation (e.g., 'must be a valid email address', 'required field missing')
|
|
required:
|
|
- field
|
|
- description
|
|
description: FieldViolation describes a single validation error for a specific field.
|
|
ValidationError:
|
|
type: object
|
|
properties:
|
|
violations:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/FieldViolation'
|
|
description: List of validation violations
|
|
required:
|
|
- violations
|
|
description: ValidationError is returned when request validation fails. It contains a list of field violations describing what went wrong.
|
|
ListMarketQuotesRequest:
|
|
type: object
|
|
properties:
|
|
symbols:
|
|
type: array
|
|
items:
|
|
type: string
|
|
description: Ticker symbols to retrieve (e.g., ["AAPL", "^GSPC"]). Empty returns defaults.
|
|
description: ListMarketQuotesRequest specifies which stock/index symbols to retrieve.
|
|
ListMarketQuotesResponse:
|
|
type: object
|
|
properties:
|
|
quotes:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/MarketQuote'
|
|
finnhubSkipped:
|
|
type: boolean
|
|
description: True when the Finnhub API key is not configured and stock quotes were skipped.
|
|
skipReason:
|
|
type: string
|
|
description: Human-readable reason when Finnhub was skipped (e.g., "FINNHUB_API_KEY not configured").
|
|
rateLimited:
|
|
type: boolean
|
|
description: True when the upstream API rate-limited the request.
|
|
description: ListMarketQuotesResponse contains stock and index quotes.
|
|
MarketQuote:
|
|
type: object
|
|
properties:
|
|
symbol:
|
|
type: string
|
|
minLength: 1
|
|
description: Ticker symbol (e.g., "AAPL", "^GSPC").
|
|
name:
|
|
type: string
|
|
description: Human-readable name.
|
|
display:
|
|
type: string
|
|
description: Display label.
|
|
price:
|
|
type: number
|
|
format: double
|
|
description: Current price.
|
|
change:
|
|
type: number
|
|
format: double
|
|
description: Percentage change from previous close.
|
|
sparkline:
|
|
type: array
|
|
items:
|
|
type: number
|
|
format: double
|
|
description: Sparkline data points (recent price history).
|
|
required:
|
|
- symbol
|
|
description: MarketQuote represents a stock or index quote from Finnhub or Yahoo Finance.
|
|
ListCryptoQuotesRequest:
|
|
type: object
|
|
properties:
|
|
ids:
|
|
type: array
|
|
items:
|
|
type: string
|
|
description: Cryptocurrency IDs to retrieve (CoinGecko IDs). Empty returns defaults.
|
|
description: ListCryptoQuotesRequest specifies which cryptocurrencies to retrieve.
|
|
ListCryptoQuotesResponse:
|
|
type: object
|
|
properties:
|
|
quotes:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/CryptoQuote'
|
|
description: ListCryptoQuotesResponse contains cryptocurrency quotes.
|
|
CryptoQuote:
|
|
type: object
|
|
properties:
|
|
name:
|
|
type: string
|
|
description: Cryptocurrency name (e.g., "Bitcoin").
|
|
symbol:
|
|
type: string
|
|
minLength: 1
|
|
description: Ticker symbol (e.g., "BTC").
|
|
price:
|
|
type: number
|
|
format: double
|
|
description: Current price in USD.
|
|
change:
|
|
type: number
|
|
format: double
|
|
description: 24-hour percentage change.
|
|
sparkline:
|
|
type: array
|
|
items:
|
|
type: number
|
|
format: double
|
|
description: Sparkline data points (recent price history).
|
|
required:
|
|
- symbol
|
|
description: CryptoQuote represents a cryptocurrency quote from CoinGecko.
|
|
ListCommodityQuotesRequest:
|
|
type: object
|
|
properties:
|
|
symbols:
|
|
type: array
|
|
items:
|
|
type: string
|
|
description: Commodity symbols to retrieve (Yahoo symbols). Empty returns defaults.
|
|
description: ListCommodityQuotesRequest specifies which commodities to retrieve.
|
|
ListCommodityQuotesResponse:
|
|
type: object
|
|
properties:
|
|
quotes:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/CommodityQuote'
|
|
description: ListCommodityQuotesResponse contains commodity quotes.
|
|
CommodityQuote:
|
|
type: object
|
|
properties:
|
|
symbol:
|
|
type: string
|
|
minLength: 1
|
|
description: Commodity symbol (e.g., "CL=F" for crude oil).
|
|
name:
|
|
type: string
|
|
description: Human-readable name.
|
|
display:
|
|
type: string
|
|
description: Display label.
|
|
price:
|
|
type: number
|
|
format: double
|
|
description: Current price.
|
|
change:
|
|
type: number
|
|
format: double
|
|
description: Percentage change from previous close.
|
|
sparkline:
|
|
type: array
|
|
items:
|
|
type: number
|
|
format: double
|
|
description: Sparkline data points.
|
|
required:
|
|
- symbol
|
|
description: CommodityQuote represents a commodity price quote from Yahoo Finance.
|
|
GetSectorSummaryRequest:
|
|
type: object
|
|
properties:
|
|
period:
|
|
type: string
|
|
description: Time period for performance calculation (e.g., "1d", "1w", "1m"). Defaults to "1d".
|
|
description: GetSectorSummaryRequest specifies parameters for retrieving sector performance.
|
|
GetSectorSummaryResponse:
|
|
type: object
|
|
properties:
|
|
sectors:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/SectorPerformance'
|
|
description: GetSectorSummaryResponse contains sector performance data.
|
|
SectorPerformance:
|
|
type: object
|
|
properties:
|
|
symbol:
|
|
type: string
|
|
minLength: 1
|
|
description: Sector symbol.
|
|
name:
|
|
type: string
|
|
description: Sector name.
|
|
change:
|
|
type: number
|
|
format: double
|
|
description: Percentage change over the measured period.
|
|
required:
|
|
- symbol
|
|
description: SectorPerformance represents performance data for a market sector.
|
|
ListStablecoinMarketsRequest:
|
|
type: object
|
|
properties:
|
|
coins:
|
|
type: array
|
|
items:
|
|
type: string
|
|
description: CoinGecko IDs to retrieve (e.g. "tether,usd-coin"). Empty returns defaults.
|
|
description: ListStablecoinMarketsRequest specifies which stablecoins to retrieve.
|
|
ListStablecoinMarketsResponse:
|
|
type: object
|
|
properties:
|
|
timestamp:
|
|
type: string
|
|
description: Timestamp of the data fetch (ISO 8601).
|
|
summary:
|
|
$ref: '#/components/schemas/StablecoinSummary'
|
|
stablecoins:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Stablecoin'
|
|
description: ListStablecoinMarketsResponse contains stablecoin market data.
|
|
StablecoinSummary:
|
|
type: object
|
|
properties:
|
|
totalMarketCap:
|
|
type: number
|
|
format: double
|
|
description: Total market cap across all queried stablecoins.
|
|
totalVolume24h:
|
|
type: number
|
|
format: double
|
|
description: Total 24h volume across all queried stablecoins.
|
|
coinCount:
|
|
type: integer
|
|
format: int32
|
|
description: Number of stablecoins returned.
|
|
depeggedCount:
|
|
type: integer
|
|
format: int32
|
|
description: Number of stablecoins in DEPEGGED state.
|
|
healthStatus:
|
|
type: string
|
|
description: 'Overall health: "HEALTHY", "CAUTION", or "WARNING".'
|
|
description: StablecoinSummary contains aggregate stablecoin market stats.
|
|
Stablecoin:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
minLength: 1
|
|
description: CoinGecko ID.
|
|
symbol:
|
|
type: string
|
|
minLength: 1
|
|
description: Ticker symbol (e.g. "USDT").
|
|
name:
|
|
type: string
|
|
description: Human-readable name.
|
|
price:
|
|
type: number
|
|
minimum: 0
|
|
format: double
|
|
description: Current price in USD.
|
|
deviation:
|
|
type: number
|
|
format: double
|
|
description: Deviation from $1.00 peg, as a percentage.
|
|
pegStatus:
|
|
type: string
|
|
description: 'Peg status: "ON PEG", "SLIGHT DEPEG", or "DEPEGGED".'
|
|
marketCap:
|
|
type: number
|
|
format: double
|
|
description: Market capitalization in USD.
|
|
volume24h:
|
|
type: number
|
|
format: double
|
|
description: 24-hour trading volume in USD.
|
|
change24h:
|
|
type: number
|
|
format: double
|
|
description: 24-hour price change percentage.
|
|
change7d:
|
|
type: number
|
|
format: double
|
|
description: 7-day price change percentage.
|
|
image:
|
|
type: string
|
|
description: Coin image URL.
|
|
required:
|
|
- id
|
|
- symbol
|
|
description: Stablecoin represents a single stablecoin with peg health data.
|
|
ListEtfFlowsRequest:
|
|
type: object
|
|
description: ListEtfFlowsRequest is empty; the handler uses a fixed list of BTC spot ETFs.
|
|
ListEtfFlowsResponse:
|
|
type: object
|
|
properties:
|
|
timestamp:
|
|
type: string
|
|
description: Timestamp of the data fetch (ISO 8601).
|
|
summary:
|
|
$ref: '#/components/schemas/EtfFlowsSummary'
|
|
etfs:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/EtfFlow'
|
|
rateLimited:
|
|
type: boolean
|
|
description: True when the upstream API rate-limited the request.
|
|
description: ListEtfFlowsResponse contains BTC spot ETF flow data.
|
|
EtfFlowsSummary:
|
|
type: object
|
|
properties:
|
|
etfCount:
|
|
type: integer
|
|
format: int32
|
|
description: Number of ETFs with data.
|
|
totalVolume:
|
|
type: integer
|
|
format: int64
|
|
description: 'Total volume across all ETFs.. Warning: Values > 2^53 may lose precision in JavaScript'
|
|
totalEstFlow:
|
|
type: integer
|
|
format: int64
|
|
description: 'Total estimated flow across all ETFs.. Warning: Values > 2^53 may lose precision in JavaScript'
|
|
netDirection:
|
|
type: string
|
|
description: 'Net direction: "NET INFLOW", "NET OUTFLOW", or "NEUTRAL".'
|
|
inflowCount:
|
|
type: integer
|
|
format: int32
|
|
description: Number of ETFs with inflow.
|
|
outflowCount:
|
|
type: integer
|
|
format: int32
|
|
description: Number of ETFs with outflow.
|
|
description: EtfFlowsSummary contains aggregate ETF flow stats.
|
|
EtfFlow:
|
|
type: object
|
|
properties:
|
|
ticker:
|
|
type: string
|
|
minLength: 1
|
|
description: Ticker symbol (e.g. "IBIT").
|
|
issuer:
|
|
type: string
|
|
description: Fund issuer (e.g. "BlackRock").
|
|
price:
|
|
type: number
|
|
format: double
|
|
description: Latest closing price.
|
|
priceChange:
|
|
type: number
|
|
format: double
|
|
description: Day-over-day price change percentage.
|
|
volume:
|
|
type: integer
|
|
format: int64
|
|
description: 'Latest daily volume.. Warning: Values > 2^53 may lose precision in JavaScript'
|
|
avgVolume:
|
|
type: integer
|
|
format: int64
|
|
description: 'Average volume over prior days.. Warning: Values > 2^53 may lose precision in JavaScript'
|
|
volumeRatio:
|
|
type: number
|
|
format: double
|
|
description: Volume ratio (latest / average).
|
|
direction:
|
|
type: string
|
|
description: 'Flow direction: "inflow", "outflow", or "neutral".'
|
|
estFlow:
|
|
type: integer
|
|
format: int64
|
|
description: 'Estimated dollar flow magnitude.. Warning: Values > 2^53 may lose precision in JavaScript'
|
|
required:
|
|
- ticker
|
|
description: EtfFlow represents a single ETF with estimated flow data.
|
|
GetCountryStockIndexRequest:
|
|
type: object
|
|
properties:
|
|
countryCode:
|
|
type: string
|
|
pattern: ^[A-Z]{2}$
|
|
description: ISO 3166-1 alpha-2 country code (e.g., "US", "GB", "JP").
|
|
required:
|
|
- countryCode
|
|
description: GetCountryStockIndexRequest specifies which country's stock index to retrieve.
|
|
GetCountryStockIndexResponse:
|
|
type: object
|
|
properties:
|
|
available:
|
|
type: boolean
|
|
description: Whether stock index data is available for this country.
|
|
code:
|
|
type: string
|
|
description: ISO 3166-1 alpha-2 country code.
|
|
symbol:
|
|
type: string
|
|
description: Ticker symbol (e.g., "^GSPC").
|
|
indexName:
|
|
type: string
|
|
description: Index name (e.g., "S&P 500").
|
|
price:
|
|
type: number
|
|
format: double
|
|
description: Latest closing price.
|
|
weekChangePercent:
|
|
type: number
|
|
format: double
|
|
description: Weekly change percentage.
|
|
currency:
|
|
type: string
|
|
description: Currency of the index.
|
|
fetchedAt:
|
|
type: string
|
|
description: When the data was fetched (ISO 8601).
|
|
description: GetCountryStockIndexResponse contains the country's primary stock index data.
|