coinbase-pro-node-api
Version:
Node.js library for Coinbase Pro
141 lines (140 loc) • 3.85 kB
TypeScript
import { RequestInit } from "node-fetch";
import { FetchClient } from "rpc-request";
export declare const ApiUri = "https://api.exchange.coinbase.com";
export declare const SandboxApiUri =
"https://api-public.sandbox.exchange.coinbase.com";
export declare const DefaultProductID = "BTC-USD";
export interface ProductID {
product_id?: string;
}
export interface PagArgs {
before?: number | string;
after?: number | string;
limit?: number | string;
}
export declare type PagProductID = ProductID & PagArgs;
export interface OrderBookArgs extends ProductID {
level?: 1 | 2 | 3;
}
export interface HistoricRatesArgs {
product_id?: string;
start?: string;
end?: string;
granularity: 60 | 300 | 900 | 3600 | 21600 | 86400;
}
export interface ProductInfo {
id: string;
base_currency: string;
quote_currency: string;
base_min_size: string;
base_max_size: string;
base_increment: string;
quote_increment: string;
display_name: string;
min_market_funds: string;
max_market_funds: string;
margin_enabled: boolean;
fx_stablecoin: boolean;
max_slippage_percentage: string;
post_only: boolean;
limit_only: boolean;
cancel_only: boolean;
trading_disabled: boolean;
status: string;
status_message: string;
auction_mode: boolean;
}
export interface OrderBookLevel1 {
sequence: number;
bids: [[string, string, number]];
asks: [[string, string, number]];
}
export interface OrderBookLevel2 {
sequence: number;
bids: [string, string, number][];
asks: [string, string, number][];
}
export interface OrderBookLevel3 {
sequence: number;
bids: [string, string, string][];
asks: [string, string, string][];
}
export declare type OrderBook =
| OrderBookLevel1
| OrderBookLevel2
| OrderBookLevel3;
export interface Ticker {
trade_id: number;
price: string;
size: string;
time: string;
bid: string;
ask: string;
volume: string;
}
export declare type Side = "buy" | "sell";
export interface Trade {
time: string;
trade_id: number;
price: string;
size: string;
side: Side;
}
export declare type Candle = [number, number, number, number, number, number];
export interface ProductStats {
open: string;
high: string;
low: string;
volume: string;
last: string;
volume_30day: string;
}
export interface CurrencyDetails {
type: string;
symbol?: string;
sort_order: number;
push_payment_methods: string[];
processing_time_seconds?: number;
min_withdrawal_amount?: number;
network_confirmations?: number;
group_types?: string[];
crypto_address_link?: string;
crypto_transaction_link?: string;
display_name?: string;
}
export interface CurrencyInfo {
id: string;
name: string;
min_size: string;
status: string;
message: null | string;
details: CurrencyDetails;
max_precision: string;
convertible_to?: string[];
}
export interface Time {
iso: string;
epoch: number;
}
export interface PublicClientOptions {
product_id?: string;
sandbox?: boolean;
apiUri?: string;
}
export declare class PublicClient extends FetchClient<unknown> {
#private;
constructor({ product_id, sandbox, apiUri }?: PublicClientOptions);
get product_id(): string;
get apiUri(): URL;
fetch(path: string, options?: RequestInit): Promise<unknown>;
getProducts(): Promise<ProductInfo[]>;
getProduct({ product_id }?: ProductID): Promise<ProductInfo>;
getOrderBook({ product_id, ...qs }?: OrderBookArgs): Promise<OrderBook>;
getTicker({ product_id }?: ProductID): Promise<Ticker>;
getTrades({ product_id, ...qs }?: PagProductID): Promise<Trade[]>;
getHistoricRates({ product_id, ...qs }: HistoricRatesArgs): Promise<Candle[]>;
get24hrStats({ product_id }?: ProductID): Promise<ProductStats>;
getCurrencies(): Promise<CurrencyInfo[]>;
getCurrency({ id }: { id: string }): Promise<CurrencyInfo>;
getTime(): Promise<Time>;
}