Skip to content

Commit e11dc98

Browse files
authored
Add core metrics exchanges, markets, networks (#23)
* Fix generate script * Add types for exchanges, markets, networks * Add examples * Update docs * Bump version
1 parent 748d8d8 commit e11dc98

File tree

16 files changed

+2582
-99
lines changed

16 files changed

+2582
-99
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ For the full list of APIs, see the [API Reference Docs](https://docs.messari.io/
5151
| Asset | Asset Metrics | `/metrics/v2/assets/metrics` ||
5252
| Asset | Asset Price Time Series | `/metrics/v2/assets/{assetId}/metrics/price/time-series/{granularity}` ||
5353
| |
54+
| Exchanges | Exchanges | `/metrics/v1/exchanges` ||
55+
| Exchanges | Exchange Details | `/metrics/v1/exchanges/{exchangeIdentifier}` ||
56+
| Exchanges | Exchange Metrics | `/metrics/v1/exchanges/metrics` ||
57+
| Exchanges | Exchange Timeseries | `/metrics/v1/exchanges/{entityIdentifier}/metrics/{datasetSlug}/time-series/{granularity}` ||
58+
| |
59+
| Markets | Markets | `/metrics/v1/markets` ||
60+
| Markets | Market Details | `/metrics/v1/markets/{marketIdentifier}` ||
61+
| Markets | Market Metrics | `/metrics/v1/markets/metrics` ||
62+
| Markets | Market Timeseries | `/metrics/v1/markets/{entityIdentifier}/metrics/{datasetSlug}/time-series/{granularity}` ||
63+
| |
64+
| Networks | Networks | `/metrics/v1/networks` ||
65+
| Networks | Network Details | `/metrics/v1/networks/{networkIdentifier}` ||
66+
| Networks | Network Metrics | `/metrics/v1/networks/metrics` ||
67+
| Networks | Network Timeseries | `/metrics/v1/networks/{entityIdentifier}/metrics/{datasetSlug}/time-series/{granularity}` ||
68+
| |
5469
| Intel | Events | `/intel/v1/events` | 🚧 |
5570
| Intel | Events By ID | `/intel/v1/events/{eventId}` | 🚧 |
5671
| Intel | Intel Assets | `/intel/v1/assets` | 🚧 |

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
"test:watch": "pnpm -r test:watch",
99
"clean": "pnpm -r clean && rimraf typegen/openapi/dist",
1010
"lint:fix": "pnpm biome lint --write . && pnpm biome format --write .",
11-
"examples:start:asset": "pnpm --filter @messari/sdk-examples start:asset",
1211
"examples:start:ai": "pnpm --filter @messari/sdk-examples start:ai",
12+
"examples:start:asset": "pnpm --filter @messari/sdk-examples start:asset",
13+
"examples:start:exchanges": "pnpm --filter @messari/sdk-examples start:exchanges",
14+
"examples:start:markets": "pnpm --filter @messari/sdk-examples start:markets",
15+
"examples:start:networks": "pnpm --filter @messari/sdk-examples start:networks",
1316
"api:validate": "redocly lint typegen/openapi/**/*.yaml",
1417
"api:bundle": "redocly bundle typegen/openapi/index.yaml --output typegen/openapi/dist/combined.yaml",
1518
"api:docs": "redocly preview-docs typegen/openapi/index.yaml",

packages/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@messari/sdk",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"private": false,
55
"description": "Messari SDK provides a type-safe, intuitive interface for accessing Messari's suite of crypto data and AI APIs.",
66
"author": "Messari Engineering",

packages/api/src/client/base.ts

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,27 @@ import type {
6363
getAssetTimeseriesWithGranularityParameters,
6464
getAssetTimeseriesWithGranularityResponse,
6565
TimeseriesMetadata,
66+
getExchangesParameters,
67+
getExchangesResponse,
68+
getExchangeParameters,
69+
getExchangeResponse,
70+
getExchangeTimeseriesParameters,
71+
getExchangeTimeseriesResponse,
72+
getExchangeMetricsResponse,
73+
getNetworkTimeseriesResponse,
74+
getNetworkTimeseriesParameters,
75+
getNetworkMetricsResponse,
76+
getMarketMetricsResponse,
77+
getMarketTimeseriesParameters,
78+
getMarketTimeseriesResponse,
79+
getNetworksParameters,
80+
getNetworksResponse,
81+
getNetworkParameters,
82+
getNetworkResponse,
83+
getMarketsResponse,
84+
getMarketsParameters,
85+
getMarketResponse,
86+
getMarketParameters,
6687
createWatchlistResponse,
6788
createWatchlistParameters,
6889
getWatchlistParameters,
@@ -167,6 +188,126 @@ export interface AssetInterface {
167188
): Promise<APIResponseWithMetadata<getAssetTimeseriesWithGranularityResponse, TimeseriesMetadata>>;
168189
}
169190

191+
/**
192+
* Interface for the Exchanges API methods
193+
*/
194+
export interface ExchangesInterface {
195+
/**
196+
* Gets a list of all exchanges
197+
* @param params Parameters for filtering exchanges
198+
* @param options Optional request configuration
199+
* @returns A paginated result of exchanges
200+
*/
201+
getExchanges(params?: getExchangesParameters, options?: RequestOptions): Promise<APIResponseWithMetadata<getExchangesResponse>>;
202+
203+
/**
204+
* Gets a specific exchange by ID
205+
* @param params Parameters for the exchange ID
206+
* @param options Optional request configuration
207+
* @returns A promise resolving to the exchange
208+
*/
209+
getExchangeById(params: getExchangeParameters, options?: RequestOptions): Promise<APIResponseWithMetadata<getExchangeResponse>>;
210+
211+
/**
212+
* Gets a list of all metrics for an exchange
213+
* @param params Parameters for the exchange ID
214+
* @param options Optional request configuration
215+
* @returns A promise resolving to the metrics
216+
*/
217+
getExchangeMetrics(options?: RequestOptions): Promise<APIResponseWithMetadata<getExchangeMetricsResponse>>;
218+
219+
/**
220+
* Gets timeseries data for a specific exchange and metric group
221+
* @param params Parameters for the exchange ID and metric group
222+
* @param options Optional request configuration
223+
* @returns A promise resolving to the timeseries data
224+
*/
225+
getExchangeTimeseries(
226+
params: getExchangeTimeseriesParameters,
227+
options?: RequestOptions,
228+
): Promise<APIResponseWithMetadata<getExchangeTimeseriesResponse, TimeseriesMetadata>>;
229+
}
230+
231+
/**
232+
* Interface for the Networks API methods
233+
*/
234+
export interface NetworksInterface {
235+
/**
236+
* Gets a list of all networks
237+
* @param params Parameters for filtering networks
238+
* @param options Optional request configuration
239+
* @returns A paginated result of networks
240+
*/
241+
getNetworks(params?: getNetworksParameters, options?: RequestOptions): Promise<APIResponseWithMetadata<getNetworksResponse>>;
242+
243+
/**
244+
* Gets a specific exchange by ID
245+
* @param params Parameters for the exchange ID
246+
* @param options Optional request configuration
247+
* @returns A promise resolving to the exchange
248+
*/
249+
getNetworkById(params: getNetworkParameters, options?: RequestOptions): Promise<APIResponseWithMetadata<getNetworkResponse>>;
250+
251+
/**
252+
* Gets a list of all metrics for an network
253+
* @param params Parameters for the network ID
254+
* @param options Optional request configuration
255+
* @returns A promise resolving to the metrics
256+
*/
257+
getNetworkMetrics(options?: RequestOptions): Promise<APIResponseWithMetadata<getNetworkMetricsResponse>>;
258+
259+
/**
260+
* Gets timeseries data for a specific network and metric group
261+
* @param params Parameters for the network ID and metric group
262+
* @param options Optional request configuration
263+
* @returns A promise resolving to the timeseries data
264+
*/
265+
getNetworkTimeseries(
266+
params: getNetworkTimeseriesParameters,
267+
options?: RequestOptions,
268+
): Promise<APIResponseWithMetadata<getNetworkTimeseriesResponse, TimeseriesMetadata>>;
269+
}
270+
271+
/**
272+
* Interface for the Markets API methods
273+
*/
274+
export interface MarketsInterface {
275+
/**
276+
* Gets a list of all markets
277+
* @param params Parameters for filtering markets
278+
* @param options Optional request configuration
279+
* @returns A paginated result of markets
280+
*/
281+
getMarkets(params?: getMarketsParameters, options?: RequestOptions): Promise<APIResponseWithMetadata<getMarketsResponse>>;
282+
283+
/**
284+
* Gets a specific market by ID
285+
* @param params Parameters for the market ID
286+
* @param options Optional request configuration
287+
* @returns A promise resolving to the market
288+
*/
289+
getMarketById(params: getMarketParameters, options?: RequestOptions): Promise<APIResponseWithMetadata<getMarketResponse>>;
290+
291+
/**
292+
* Gets a list of all metrics for an Market
293+
* @param params Parameters for the Market ID
294+
* @param options Optional request configuration
295+
* @returns A promise resolving to the metrics
296+
*/
297+
getMarketMetrics(options?: RequestOptions): Promise<APIResponseWithMetadata<getMarketMetricsResponse>>;
298+
299+
/**
300+
* Gets timeseries data for a specific Market and metric group
301+
* @param params Parameters for the Market ID and metric group
302+
* @param options Optional request configuration
303+
* @returns A promise resolving to the timeseries data
304+
*/
305+
getMarketTimeseries(
306+
params: getMarketTimeseriesParameters,
307+
options?: RequestOptions,
308+
): Promise<APIResponseWithMetadata<getMarketTimeseriesResponse, TimeseriesMetadata>>;
309+
}
310+
170311
/**
171312
* Interface for the Intel API methods
172313
*/

packages/api/src/client/client.ts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ import {
3030
getAssetsV2ROI,
3131
getAssetTimeseries,
3232
getAssetTimeseriesWithGranularity,
33+
getExchanges,
34+
getExchange,
35+
getExchangeMetrics,
36+
getExchangeTimeseries,
37+
getNetworkTimeseries,
38+
getNetworkMetrics,
39+
getMarketMetrics,
40+
getMarketTimeseries,
41+
getNetworks,
42+
getNetwork,
43+
getMarkets,
44+
getMarket,
3345
modifyWatchlistAssets,
3446
deleteWatchlist,
3547
listWatchlists,
@@ -100,6 +112,27 @@ import type {
100112
getAssetTimeseriesWithGranularityParameters,
101113
getAssetTimeseriesWithGranularityResponse,
102114
TimeseriesMetadata,
115+
getExchangesParameters,
116+
getExchangesResponse,
117+
getExchangeResponse,
118+
getExchangeParameters,
119+
getExchangeTimeseriesResponse,
120+
getExchangeTimeseriesParameters,
121+
getExchangeMetricsResponse,
122+
getNetworkMetricsResponse,
123+
getNetworkTimeseriesParameters,
124+
getNetworkTimeseriesResponse,
125+
getMarketMetricsResponse,
126+
getMarketTimeseriesParameters,
127+
getMarketTimeseriesResponse,
128+
getNetworksResponse,
129+
getNetworksParameters,
130+
getNetworkResponse,
131+
getNetworkParameters,
132+
getMarketsParameters,
133+
getMarketsResponse,
134+
getMarketResponse,
135+
getMarketParameters,
103136
modifyWatchlistAssetsResponse,
104137
modifyWatchlistAssetsParameters,
105138
deleteWatchlistResponse,
@@ -139,6 +172,9 @@ import type {
139172
RecapsAPIInterface,
140173
ResearchInterface,
141174
TokenUnlocksInterface,
175+
ExchangesInterface,
176+
NetworksInterface,
177+
MarketsInterface,
142178
UserManagementInterface,
143179
} from "./base";
144180
import { MessariClientBase } from "./base";
@@ -720,6 +756,114 @@ export class MessariClient extends MessariClientBase {
720756
},
721757
};
722758

759+
public readonly exchanges: ExchangesInterface = {
760+
getExchanges: async (params: getExchangesParameters = {}, options?: RequestOptions) => {
761+
return this.requestWithMetadata<getExchangesResponse, PaginationMetadata>({
762+
method: getExchanges.method,
763+
path: getExchanges.path(),
764+
queryParams: pick(params, getExchanges.queryParams),
765+
options,
766+
});
767+
},
768+
769+
getExchangeById: async (params: getExchangeParameters, options?: RequestOptions) => {
770+
return this.requestWithMetadata<getExchangeResponse, PaginationMetadata>({
771+
method: getExchange.method,
772+
path: getExchange.path(params),
773+
options,
774+
});
775+
},
776+
777+
getExchangeMetrics: async (options?: RequestOptions) => {
778+
return this.requestWithMetadata<getExchangeMetricsResponse, PaginationMetadata>({
779+
method: getExchangeMetrics.method,
780+
path: getExchangeMetrics.path(),
781+
options,
782+
});
783+
},
784+
785+
getExchangeTimeseries: async (params: getExchangeTimeseriesParameters, options?: RequestOptions) => {
786+
return this.requestWithMetadata<getExchangeTimeseriesResponse, TimeseriesMetadata>({
787+
method: getExchangeTimeseries.method,
788+
path: getExchangeTimeseries.path(params),
789+
queryParams: pick(params, getExchangeTimeseries.queryParams),
790+
options,
791+
});
792+
},
793+
};
794+
795+
public readonly networks: NetworksInterface = {
796+
getNetworks: async (params: getNetworksParameters = {}, options?: RequestOptions) => {
797+
return this.requestWithMetadata<getNetworksResponse, PaginationMetadata>({
798+
method: getNetworks.method,
799+
path: getNetworks.path(),
800+
queryParams: pick(params, getNetworks.queryParams),
801+
options,
802+
});
803+
},
804+
805+
getNetworkById: async (params: getNetworkParameters, options?: RequestOptions) => {
806+
return this.requestWithMetadata<getNetworkResponse, PaginationMetadata>({
807+
method: getNetwork.method,
808+
path: getNetwork.path(params),
809+
options,
810+
});
811+
},
812+
813+
getNetworkMetrics: async (options?: RequestOptions) => {
814+
return this.requestWithMetadata<getNetworkMetricsResponse, PaginationMetadata>({
815+
method: getNetworkMetrics.method,
816+
path: getNetworkMetrics.path(),
817+
options,
818+
});
819+
},
820+
821+
getNetworkTimeseries: async (params: getNetworkTimeseriesParameters, options?: RequestOptions) => {
822+
return this.requestWithMetadata<getNetworkTimeseriesResponse, TimeseriesMetadata>({
823+
method: getNetworkTimeseries.method,
824+
path: getNetworkTimeseries.path(params),
825+
queryParams: pick(params, getNetworkTimeseries.queryParams),
826+
options,
827+
});
828+
},
829+
};
830+
831+
public readonly markets: MarketsInterface = {
832+
getMarkets: async (params: getMarketsParameters = {}, options?: RequestOptions) => {
833+
return this.requestWithMetadata<getMarketsResponse, PaginationMetadata>({
834+
method: getMarkets.method,
835+
path: getMarkets.path(),
836+
queryParams: pick(params, getMarkets.queryParams),
837+
options,
838+
});
839+
},
840+
841+
getMarketById: async (params: getMarketParameters, options?: RequestOptions) => {
842+
return this.requestWithMetadata<getMarketResponse, PaginationMetadata>({
843+
method: getMarket.method,
844+
path: getMarket.path(params),
845+
options,
846+
});
847+
},
848+
849+
getMarketMetrics: async (options?: RequestOptions) => {
850+
return this.requestWithMetadata<getMarketMetricsResponse, PaginationMetadata>({
851+
method: getMarketMetrics.method,
852+
path: getMarketMetrics.path(),
853+
options,
854+
});
855+
},
856+
857+
getMarketTimeseries: async (params: getMarketTimeseriesParameters, options?: RequestOptions) => {
858+
return this.requestWithMetadata<getMarketTimeseriesResponse, TimeseriesMetadata>({
859+
method: getMarketTimeseries.method,
860+
path: getMarketTimeseries.path(params),
861+
queryParams: pick(params, getMarketTimeseries.queryParams),
862+
options,
863+
});
864+
},
865+
};
866+
723867
/**
724868
* @deprecated Intel is Work-in-Progress and not production ready
725869
*/

0 commit comments

Comments
 (0)