getPrice
getPrice method is used to fetch the latest price for a single or multiple tokens

Get the latest price for a single token

getPrice(symbol: string, opts?: GetPriceOptions): Promise<PriceData>
Returns the latest price for a single symbol
Parameters:
Name
Type
Description
symbol
string
Token symbol (string)
opts?
GetPriceOptions
Optional params (object)
  • opts.provider: provider name (string)
  • opts.verifySignature: enable signature verification (boolean)
Returns: Promise<PriceData>
The latest price for the token
Defined in: limestone-api.ts:59

Get the latest price for multiple tokens

getPrice(symbols: string[], opts?: GetPriceOptions): Promise<{ [token: string]: PriceData; }>
Returns the latest price for several symbols
Parameters:
Name
Type
Description
symbols
string[]
Token symbols (array of strings)
opts?
GetPriceOptions
Optional params (object)
  • opts.provider: provider name (string)
  • opts.verifySignature: enable signature verification (boolean)
Returns: Promise<{ [token: string]: PriceData; }>
The latest price for the tokens
Defined in: limestone-api.ts:70

Examples

Get the latest price for a single token

const price = await limestone.getPrice("AR");
console.log(price.value); // latest price value for AR token (in USD)
console.log(price.timestamp); // the exact timestamp of the price
All the prices are denominated in USD. You can fetch price data for BTC, ETH, AR, EUR and any other of 100+ supported tokens

Price data format

{
value: 123.23, // Number: Price value in USD
timestamp: 1617146511173, // Number: Timestamp (ms) for price
provider: "I-5rWUehEv-MjdK9gFw09RxfSLQX9DIHxG614Wf8qo0", // String: Provider arweave address
permawebTx: "V8FUU0BG4kVOJwKWHzgkn1aEFm-eanhqqEXfPFY7pmI", // String: Arweave transaction id
source: {"coingecko": 123,"sushiswap": 123.23,"uniswap": 123.35}, // Object: Prices from different sources
}

Fetch price using promises

// As async/await is only a syntactic sugar on Javascript
// Promises you can use them in a "standard" way
const price = limestone.getPrice("AR").then((price) => {
console.log(price.value); // latest price value for AR token
});

Get the latest prices for multiple tokens

To fetch prices for multiple tokens use the getPrice method and pass an array with a subset of supported tokens.
const prices = await limestone.getPrice(["BTC", "ETH", "AR", "EUR"]);
console.log(prices); // Example output below
/*
{
"BTC": {
value: 58953.39,
timestamp: 1617152802779,
...
},
"ETH": {
value: 1856.75,
timestamp: 1617152802779,
...
},
...
}
*/
console.log(prices["BTC"].value); // latest price value for BTC
console.log(prices["ETH"].value); // latest price value for ETH
console.log(prices["AR"].value); // latest price value for AR
Copy link
Outline
Get the latest price for a single token
Get the latest price for multiple tokens
Examples