mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-22 21:59:44 +03:00
Merge pull request #164 from orionprotocol/get-all-tickers
get all tickers
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@orionprotocol/sdk",
|
"name": "@orionprotocol/sdk",
|
||||||
"version": "0.19.36",
|
"version": "0.19.37-rc1",
|
||||||
"description": "Orion Protocol SDK",
|
"description": "Orion Protocol SDK",
|
||||||
"main": "./lib/index.cjs",
|
"main": "./lib/index.cjs",
|
||||||
"module": "./lib/index.js",
|
"module": "./lib/index.js",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { fetchWithValidation } from 'simple-typed-fetch';
|
import { fetchWithValidation } from 'simple-typed-fetch';
|
||||||
import type { BasicAuthCredentials, Exchange } from '../../types.js';
|
import type { BasicAuthCredentials, Exchange } from '../../types.js';
|
||||||
import { statisticsOverviewSchema, topPairsStatisticsSchema } from './schemas/index.js';
|
import { allTickersSchema, statisticsOverviewSchema, topPairsStatisticsSchema } from './schemas/index.js';
|
||||||
import candlesSchema from './schemas/candlesSchema.js';
|
import candlesSchema from './schemas/candlesSchema.js';
|
||||||
import { PriceFeedWS } from './ws/index.js';
|
import { PriceFeedWS } from './ws/index.js';
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ class PriceFeed {
|
|||||||
this.getCandles = this.getCandles.bind(this);
|
this.getCandles = this.getCandles.bind(this);
|
||||||
this.getStatisticsOverview = this.getStatisticsOverview.bind(this);
|
this.getStatisticsOverview = this.getStatisticsOverview.bind(this);
|
||||||
this.getTopPairStatistics = this.getTopPairStatistics.bind(this);
|
this.getTopPairStatistics = this.getTopPairStatistics.bind(this);
|
||||||
|
this.getAllTickers = this.getAllTickers.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
get basicAuthHeaders() {
|
get basicAuthHeaders() {
|
||||||
@@ -77,6 +78,14 @@ class PriceFeed {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAllTickers = () => {
|
||||||
|
return fetchWithValidation(
|
||||||
|
`${this.tickersUrl}/all`,
|
||||||
|
allTickersSchema,
|
||||||
|
{ headers: this.basicAuthHeaders }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
get wsUrl() {
|
get wsUrl() {
|
||||||
const url = new URL(this.apiUrl);
|
const url = new URL(this.apiUrl);
|
||||||
const wsProtocol = url.protocol === 'https:' ? 'wss' : 'ws';
|
const wsProtocol = url.protocol === 'https:' ? 'wss' : 'ws';
|
||||||
@@ -90,6 +99,10 @@ class PriceFeed {
|
|||||||
get statisticsUrl() {
|
get statisticsUrl() {
|
||||||
return `${this.apiUrl}/api/v1/statistics`;
|
return `${this.apiUrl}/api/v1/statistics`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get tickersUrl() {
|
||||||
|
return `${this.apiUrl}/api/v1/ticker`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export * as schemas from './schemas/index.js';
|
export * as schemas from './schemas/index.js';
|
||||||
|
|||||||
10
src/services/PriceFeed/schemas/allTickersSchema.ts
Normal file
10
src/services/PriceFeed/schemas/allTickersSchema.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
const tickerSchema = z.object({
|
||||||
|
pair: z.string(),
|
||||||
|
volume24: z.number(),
|
||||||
|
change24: z.number(),
|
||||||
|
lastPrice: z.number(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const allTickersSchema = tickerSchema.array();
|
||||||
@@ -3,3 +3,4 @@ export {
|
|||||||
statisticsOverviewSchema,
|
statisticsOverviewSchema,
|
||||||
topPairsStatisticsSchema,
|
topPairsStatisticsSchema,
|
||||||
} from './statisticsSchema.js';
|
} from './statisticsSchema.js';
|
||||||
|
export { allTickersSchema } from './allTickersSchema.js';
|
||||||
|
|||||||
Reference in New Issue
Block a user