Skip to main content

GET /prices/

Get the current price or price at a specific timestamp for an asset. Supports linear interpolation between data points.

Path Parameters

symbol
string
required
Asset symbol. Supported values:
  • ETH / ETHEREUM / WETH
  • BTC / BITCOIN / WBTC
  • UNI / UNISWAP
  • AAVE
  • STETH / WSTETH

Query Parameters

timestamp
integer
Unix timestamp in seconds. If not provided, returns the current price (based on latest available data).

Response

symbol
string
The asset symbol
price
number
The asset price in USD (close price, linearly interpolated if needed)
timestamp
integer
The timestamp for which the price was retrieved

Example Request

# Get current ETH price
curl http://localhost:8080/prices/ETH

# Get ETH price at specific timestamp
curl "http://localhost:8080/prices/ETH?timestamp=1704067200"

# Get BTC price
curl http://localhost:8080/prices/BTC

Example Response

{
  "symbol": "ETH",
  "price": 3250.75,
  "timestamp": 1704067200
}

GET /prices//historical

Get OHLC (Open, High, Low, Close) historical price data for an asset within a time range.

Path Parameters

symbol
string
required
Asset symbol. See supported values in GET /prices/

Query Parameters

start
integer
required
Start timestamp in Unix epoch seconds
end
integer
required
End timestamp in Unix epoch seconds (must be >= start)

Response

symbol
string
The asset symbol
data
array
Array of OHLC price data points
timestamp
integer
Unix timestamp in seconds
open
number
Opening price
high
number
Highest price in the period
low
number
Lowest price in the period
close
number
Closing price
volume
number
Trading volume in the period
start
integer
Start timestamp of the range
end
integer
End timestamp of the range

Example Request

# Get ETH historical data for a day
curl "http://localhost:8080/prices/ETH/historical?start=1704067200&end=1704153600"

# Get BTC historical data
curl "http://localhost:8080/prices/BTC/historical?start=1704067200&end=1704153600"

Example Response

{
  "symbol": "ETH",
  "data": [
    {
      "timestamp": 1704067200,
      "open": 3200.50,
      "high": 3285.00,
      "low": 3180.25,
      "close": 3250.75,
      "volume": 12500000.0
    },
    {
      "timestamp": 1704070800,
      "open": 3250.75,
      "high": 3310.00,
      "low": 3245.00,
      "close": 3290.50,
      "volume": 13200000.0
    }
  ],
  "start": 1704067200,
  "end": 1704153600
}

GET /prices/assets

List all available assets that have price data available.

Response

root
array
Array of asset symbols (strings)

Example Request

curl http://localhost:8080/prices/assets

Example Response

[
  "ETH",
  "BTC",
  "UNI",
  "AAVE",
  "STETH"
]

Data Source

Price data is loaded from CSV files in the data/prices/ directory. Files follow the naming convention {asset}_consolidated.csv with the following format:
timestamp,open,high,low,close,volume
1704067200,3200.50,3285.00,3180.25,3250.75,12500000.0

Notes

  • Timestamps can be provided in seconds or milliseconds (automatically normalized)
  • Price interpolation is linear between data points
  • If a timestamp is before the first data point, the first available price is returned
  • If a timestamp is after the last data point, the last available price is returned
  • Historical data is cached in memory for performance

Error Responses

Invalid Asset

curl http://localhost:8080/prices/INVALID
{
  "error": "bad request: Unsupported asset: INVALID"
}

Invalid Time Range

curl "http://localhost:8080/prices/ETH/historical?start=1704153600&end=1704067200"
{
  "error": "internal error: start_ts (1704153600) must be <= end_ts (1704067200)"
}

Missing Data File

{
  "error": "internal error: Price data file not found for ETH: /path/to/data/prices/eth_consolidated.csv"
}

Build docs developers (and LLMs) love