Socket
Socket
Sign inDemoInstall

limestone-api

Package Overview
Dependencies
17
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.3 to 3.0.4

13

lib/limestone-api.d.ts

@@ -1,2 +0,2 @@

import { PriceData, GetPriceOptions, LimestoneApiConfig, GetHistoricalPriceOptions, GetHistoricalPriceForIntervalOptions } from "./types";
import { PriceData, GetPriceOptions, LimestoneApiConfig, GetHistoricalPriceOptions, GetHistoricalPriceForSingleTokenOptions } from "./types";
export default class LimestoneApi {

@@ -11,2 +11,3 @@ private defaultProvider;

constructor(limestoneConfig?: LimestoneApiConfig);
setCacheApiUrl(cacheApiUrl: string): void;
/**

@@ -61,3 +62,5 @@ * Returns the latest price for a single symbol

* @param symbol - Token symbol
* @param opts - Options object. It must contain startDate, endDate, and interval properties.
* @param opts - Options object.
* It must contain either a startDate, an endDate, and interval properties
* or an offset and a limit (used for pagination) properties.
* * opts.startDate: Start time for the time range (date | timestamp | string)

@@ -67,2 +70,4 @@ * * opts.endDate: End time for the time range (date | timestamp | string)

* * opts.provider: provider name (string)
* * opts.offset: query offset (number)
* * opts.limit: query limit (number)
* * opts.verifySignature: enable signature verification (boolean)

@@ -72,3 +77,3 @@ * @returns The historical prices for the symbol with the passed interval

*/
getHistoricalPrice(symbol: string, opts: GetHistoricalPriceForIntervalOptions): Promise<PriceData[]>;
getHistoricalPrice(symbol: string, opts: GetHistoricalPriceForSingleTokenOptions): Promise<PriceData[]>;
/**

@@ -105,3 +110,3 @@ * Returns the historical prices for several tokens

private tryToGetPriceFromGQL;
private getHistoricalPricesInIntervalForOneSymbol;
private getHistoricalPricesForOneSymbol;
}

@@ -75,2 +75,5 @@ "use strict";

}
LimestoneApi.prototype.setCacheApiUrl = function (cacheApiUrl) {
this.cacheProxy.setCacheApiUrl(cacheApiUrl);
};
LimestoneApi.prototype.getPrice = function (symbolOrSymbols, opts) {

@@ -129,4 +132,4 @@ if (opts === void 0) { opts = {}; }

if (!(typeof symbolOrSymbols === "string")) return [3 /*break*/, 6];
if (!(opts.interval !== undefined)) return [3 /*break*/, 4];
return [4 /*yield*/, this.getHistoricalPricesInIntervalForOneSymbol({
if (!(opts.interval !== undefined || opts.limit !== undefined)) return [3 /*break*/, 4];
return [4 /*yield*/, this.getHistoricalPricesForOneSymbol({
symbol: symbolOrSymbols,

@@ -136,2 +139,4 @@ fromTimestamp: getTimestamp(opts.startDate),

interval: opts.interval,
offset: opts.offset,
limit: opts.limit,
provider: provider,

@@ -350,3 +355,3 @@ shouldVerifySignature: shouldVerifySignature,

};
LimestoneApi.prototype.getHistoricalPricesInIntervalForOneSymbol = function (args) {
LimestoneApi.prototype.getHistoricalPricesForOneSymbol = function (args) {
return __awaiter(this, void 0, void 0, function () {

@@ -364,2 +369,4 @@ var prices, _i, prices_2, price;

"interval",
"offset",
"limit",
]))];

@@ -394,2 +401,5 @@ case 1:

function getTimestamp(date) {
if (lodash_1.default.isUndefined(date)) {
return undefined;
}
return new Date(date).getTime();

@@ -396,0 +406,0 @@ }

@@ -1,2 +0,2 @@

import { ConvertableToDate, PriceData } from "./types";
import { ConvertableToDate, LimestoneApiConfig, PriceData } from "./types";
declare type QueryParams = {

@@ -99,3 +99,3 @@ symbols: string[];

*/
exec(): Promise<QueryResultType>;
exec(limestoneApiConfig?: LimestoneApiConfig): Promise<QueryResultType>;
}

@@ -102,0 +102,0 @@ /**

@@ -219,3 +219,3 @@ "use strict";

*/
LimestoneQueryExecutable.prototype.exec = function () {
LimestoneQueryExecutable.prototype.exec = function (limestoneApiConfig) {
return __awaiter(this, void 0, void 0, function () {

@@ -226,3 +226,3 @@ var limestone, symbols, symbolOrSymbols, _a, startDate, endDate, date, interval, diff;

case 0:
limestone = new limestone_api_1.default();
limestone = new limestone_api_1.default(limestoneApiConfig);
symbols = this.params.symbols;

@@ -229,0 +229,0 @@ if (!(symbols.length > 0)) return [3 /*break*/, 5];

@@ -5,2 +5,3 @@ import { PriceDataWithSignature } from "../types";

constructor(cacheApiUrl: string);
setCacheApiUrl(cacheApiUrl: string): void;
getPrice(args: {

@@ -21,6 +22,8 @@ symbol: string;

provider: string;
interval: number;
fromTimestamp: number;
toTimestamp: number;
fromTimestamp?: number;
toTimestamp?: number;
interval?: number;
offset?: number;
limit?: number;
}): Promise<PriceDataWithSignature[]>;
}

@@ -43,2 +43,3 @@ "use strict";

var axios_1 = __importDefault(require("axios"));
var lodash_1 = __importDefault(require("lodash"));
var CacheProxy = /** @class */ (function () {

@@ -48,2 +49,5 @@ function CacheProxy(cacheApiUrl) {

}
CacheProxy.prototype.setCacheApiUrl = function (cacheApiUrl) {
this.cacheApiUrl = cacheApiUrl;
};
CacheProxy.prototype.getPrice = function (args) {

@@ -103,6 +107,8 @@ return __awaiter(this, void 0, void 0, function () {

return __awaiter(this, void 0, void 0, function () {
var data;
var params, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, axios_1.default.get(this.cacheApiUrl, { params: args })];
case 0:
params = lodash_1.default.pickBy(args, function (prop) { return !lodash_1.default.isUndefined(prop); });
return [4 /*yield*/, axios_1.default.get(this.cacheApiUrl, { params: params })];
case 1:

@@ -109,0 +115,0 @@ data = (_a.sent()).data;

@@ -33,3 +33,11 @@ export declare type ConvertableToDate = Date | number | string;

}
export interface GetHistoricalPriceForIntervalOptions extends GetPriceOptions {
export declare type GetHistoricalPriceForSingleTokenOptions = GetHistoricalPriceInTimeRangeOptions | GetHistoricalPriceWithPaginationOptions;
interface GetHistoricalPriceWithPaginationOptions extends GetPriceOptions {
offset: number;
limit: number;
startDate?: ConvertableToDate;
endDate?: ConvertableToDate;
interval?: number;
}
interface GetHistoricalPriceInTimeRangeOptions extends GetPriceOptions {
startDate: ConvertableToDate;

@@ -39,1 +47,2 @@ endDate: ConvertableToDate;

}
export {};
{
"name": "limestone-api",
"version": "3.0.3",
"version": "3.0.4",
"description": "Javascript library for fetching trusted token pricing data from Limestone data ecosystem",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -219,2 +219,14 @@ # Limestone API

### Get prices with pagination
To fetch prices with pagination specify token symbol as the first argument of the `getHistoricalPrice` method, and `offset` with `limit` as properties of the second argument.
💡 Note: pagination is supported only for a single token.
```js
const prices = await limestone.getHistoricalPrices("AR", {
offset: 1000,
limit: 100,
});
```
----------------------------------------------

@@ -235,2 +247,26 @@

### Using a custom cache api url
#### Option 1. Using a setCacheApiUrl method
```js
limestone.setCacheApiUrl("http://localhost:9000/prices");
limestone.getPrice("AR").then(console.log);
```
#### Option 2. Initialising a new limestone api instance with a cacheApiUrl param
```js
const limestoneApi = new limestone.LimestoneApi({
cacheApiUrl: "http://localhost:9000/prices",
});
limestoneApi.getPrice("AR").then(console.log);
```
💡 Note: To use a custom cache api url with the limestone fluent interface you should pass a `cacheApiUrl` as an argument of the `exec` method each time you make a query.
```js
limestone.query().symbol("AR").latest().exec({
cacheApiUrl: "http://localhost:9000/prices",
}).then(console.log);
```
----------------------------------------------
### Get prices from Arweave

@@ -237,0 +273,0 @@ By default, Limestone API fetches data from the Limestone cache layer. It works way faster than fetching directly from Arweave Blockchain. Even so, thanks to signature verification prices data is still trusted and secure.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc