init
This commit is contained in:
14
packages/core/market/index.ts
Normal file
14
packages/core/market/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {ApiResponse} from "./types";
|
||||
|
||||
export async function collect_gainers_losers(x: { apiKey: string, limit: number }): Promise<ApiResponse> {
|
||||
const { apiKey, limit } = x;
|
||||
|
||||
//
|
||||
const data: ApiResponse = await fetch(`https://pro-api.coinmarketcap.com/v1/cryptocurrency/trending/gainers-losers?limit=${limit}`, {
|
||||
headers: {
|
||||
"x-cmc_pro_api_key": apiKey
|
||||
}
|
||||
}).then((symbolDataRequest) => symbolDataRequest.json());
|
||||
|
||||
return data;
|
||||
}
|
48
packages/core/market/types.ts
Normal file
48
packages/core/market/types.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
type Quote = {
|
||||
price: number;
|
||||
volume_24h: number;
|
||||
percent_change_1h: number;
|
||||
percent_change_24h: number;
|
||||
percent_change_7d: number;
|
||||
market_cap: number;
|
||||
last_updated: string;
|
||||
};
|
||||
|
||||
type Platform = null;
|
||||
|
||||
type Tag = string;
|
||||
|
||||
type Data = {
|
||||
id: number;
|
||||
name: string;
|
||||
symbol: string;
|
||||
slug: string;
|
||||
cmc_rank?: number;
|
||||
num_market_pairs: number;
|
||||
circulating_supply: number;
|
||||
total_supply: number;
|
||||
max_supply: number;
|
||||
last_updated: string;
|
||||
date_added: string;
|
||||
tags: Tag[];
|
||||
platform: Platform;
|
||||
quote: {
|
||||
USD: Quote;
|
||||
BTC?: Quote;
|
||||
ETH?: Quote;
|
||||
};
|
||||
};
|
||||
|
||||
type Status = {
|
||||
timestamp: string;
|
||||
error_code: number;
|
||||
error_message: string | null;
|
||||
elapsed: number;
|
||||
credit_count: number;
|
||||
};
|
||||
|
||||
export type ApiResponse = {
|
||||
data: Data[];
|
||||
status: Status;
|
||||
};
|
||||
|
Reference in New Issue
Block a user