# Rates API v0.1
The rates API is a public interface for getting rates data used by the Sense Portal (opens new window).
# Error Codes
Error Code | Description |
---|---|
405 | A method other than GET was used. |
500 | An unexpected server error occured. |
# Summary
Get an overview of the rates data available from this API. This lists all of the assets available, and includes a 30 days of daily APY data for each.
# Endpoint
GET /api/v0.1/rates/summary
# Response
Status: 200
{
daily: [number, number][], // [<iso_date_string>, <apy>][]
protocol: string,
underlying: string
}[]
# Latest
Get the most recent data point for a specific ticker. This includes the APY rate for the asset as well as some context.
# Endpoint
GET /api/v0.1/rates/<ticker>/latest
# Response
Status: 200
{
timestamp: string;
block: number;
ticker: string;
protocol: string;
chain: string;
underlying: string;
earn: null | number; // Lending rate if it's a lending protocol (APY)
borrow: null | number; // Borrow rate if it's a lending protocol (APR)
tal: null | number; // Total asset locked in units of underlying
}
# Series
Get a timeseries of rates data bewteen two timestamps in ascending order.
# Endpoint
GET /api/v0.1/rates/<ticker>/series
# Parameters
Name | Type |
---|---|
ticker | Asset ticker |
start | ISO date string |
end | ISO date string |
resolution | Resolution (1H or 1D) |
# Response
Status: 200
[string, number, number][] // [<iso_date_string>, <apy>, <tal>][]
# Example Usage
// Establish parameters
const ticker = "cDAI";
const startTime = new Date("2021-06-01T00:00:00Z").toISOString();
const endTime = new Date().toISOString();
const resolution = "1H";
// Build the query
const base = `http://app.sense.finance/api/v0.1/rates/${symbol}/timeseries`;
const query = `${base}?from=${startTime}&to=${endTime}&resolution=${resolution}`;
// Fetch
const cDaiRates = await fetch(query).then(resp => resp.json());
// [['2021-08-21T00:00:00.000Z', 14.32297, 21032221.63], ['2021-08-22T00:00:00.000Z', 14.1189, 21042020.63], ...]