mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-13 21:52:36 +03:00
get all tickers
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.19.36",
|
||||
"version": "0.19.37-rc1",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/index.cjs",
|
||||
"module": "./lib/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fetchWithValidation } from 'simple-typed-fetch';
|
||||
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 { PriceFeedWS } from './ws/index.js';
|
||||
|
||||
@@ -23,6 +23,7 @@ class PriceFeed {
|
||||
this.getCandles = this.getCandles.bind(this);
|
||||
this.getStatisticsOverview = this.getStatisticsOverview.bind(this);
|
||||
this.getTopPairStatistics = this.getTopPairStatistics.bind(this);
|
||||
this.getAllTickers = this.getAllTickers.bind(this);
|
||||
}
|
||||
|
||||
get basicAuthHeaders() {
|
||||
@@ -77,6 +78,14 @@ class PriceFeed {
|
||||
);
|
||||
}
|
||||
|
||||
getAllTickers = () => {
|
||||
return fetchWithValidation(
|
||||
`${this.tickersUrl}/all`,
|
||||
allTickersSchema,
|
||||
{ headers: this.basicAuthHeaders }
|
||||
);
|
||||
}
|
||||
|
||||
get wsUrl() {
|
||||
const url = new URL(this.apiUrl);
|
||||
const wsProtocol = url.protocol === 'https:' ? 'wss' : 'ws';
|
||||
@@ -90,6 +99,10 @@ class PriceFeed {
|
||||
get statisticsUrl() {
|
||||
return `${this.apiUrl}/api/v1/statistics`;
|
||||
}
|
||||
|
||||
get tickersUrl() {
|
||||
return `${this.apiUrl}/api/v1/ticker`;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
topPairsStatisticsSchema,
|
||||
} from './statisticsSchema.js';
|
||||
export { allTickersSchema } from './allTickersSchema.js';
|
||||
|
||||
Reference in New Issue
Block a user