@coinset/okex
Universal OKEX API client
:children_crossing: This is not official
Public API
A request for an entry point that does not require authentication.
fetchTicker
Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours. Docs
example:
import { fetchTicker } from "https://deno.land/x/okex@$VERSION/mod.ts";
await fetchTicker({ instId: "BTC-USD-SWAP" });
parameters:
type TickerOptions = {
instId: string;
};
returns:
type TickerResponse = {
code: "0";
msg: "";
data: {
instType: InstType;
instId: string;
last: number;
lastSz: number;
askPx: number;
askSz: number;
bidPx: number;
bidSz: number;
open24h: number;
high24h: number;
low24h: number;
volCcy24h: number;
vol24h: number;
sodUtc0: number;
sodUtc8: number;
ts: number;
}[];
};
fetchTickers
Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours. Docs
example:
import { fetchTickers } from "https://deno.land/x/okex@$VERSION/mod.ts";
await fetchTickers({ instType: "SPOT" });
parameters:
type InstType = "SPOT" | "MARGIN" | "SWAP" | "FUTURES" | "OPTION";
type TickersOptions = {
instType: Exclude<InstType, "OPTION">;
uly?: string | undefined;
} | {
instType: Extract<InstType, "OPTION">;
uly: string;
};
returns:
type TickersResponse = {
code: "0";
msg: "";
data: {
instType: InstType;
instId: string;
last: number;
lastSz: number;
askPx: number;
askSz: number;
bidPx: number;
bidSz: number;
open24h: number;
high24h: number;
low24h: number;
volCcy24h: number;
vol24h: number;
sodUtc0: number;
sodUtc8: number;
ts: number;
}[];
};
fetchIndexTickers
Retrieve index tickers. Docs
example:
import { fetchIndexTickers } from "https://deno.land/x/okex@$VERSION/mod.ts";
await fetchIndexTickers({ quoteCcy: "BTC" });
await fetchIndexTickers({ instId: "BTC-USD" });
parameters:
type IndexTickersOptions =
| ({
quoteCcy: "USD" | "USDT" | "BTC";
} & {
instId?: undefined;
})
| ({
instId: string;
} & {
quoteCcy?: undefined;
});
returns:
type IndexTickersResponse = {
code: "0";
msg: "";
data: {
instId: string;
idxPx: number;
high24h: number;
low24h: number;
open24h: number;
sodUtc0: number;
sodUtc8: number;
ts: number;
}[];
};
fetchInstruments
Retrieve a list of instruments with open contracts. Docs
example:
import { fetchInstruments } from "https://deno.land/x/okex@$VERSION/mod.ts";
await fetchInstruments({ instType: "SPOT" });
parameters:
type InstrumentsOptions =
& {
instId?: string | undefined;
}
& ({
instType: "SPOT" | "MARGIN" | "SWAP" | "FUTURES";
uly?: string | undefined;
} | {
instType: "OPTION";
uly: string;
});
returns:
type InstType = "SPOT" | "MARGIN" | "SWAP" | "FUTURES" | "OPTION";
type InstrumentsResponse = {
code: "0";
msg: "";
data: {
instType: InstType;
instId: string;
uly: string;
category: string;
baseCcy: string;
quoteCcy: string;
settleCcy: string;
ctVal: number;
ctMult: number;
ctValCcy: string;
optType: "C" | "P" | "";
stk: string;
listTime: number;
expTime: number;
lever: number;
tickSz: number;
lotSz: number;
minSz: number;
ctType: "linear" | "inverse" | "";
alias: "this_week" | "next_week" | "quarter" | "next_quarter" | "";
state: "live" | "suspend" | "preopen" | "settlement";
}[];
};
fetchUSD24hVolume
The 24-hour trading volume is calculated on a rolling basis, using USD as the pricing unit. Docs
example:
import { fetchUSD24hVolume } from "https://deno.land/x/okex@$VERSION/mod.ts";
await fetchUSD24hVolume();
returns:
type USD24hVolumeResponse = {
code: "0";
msg: "";
data: {
volUsd: number;
volCny: number;
ts: number;
};
};
fetchState
Get event status of system upgrade. Docs
example:
import { fetchStatus } from "https://deno.land/x/okex@$VERSION/mod.ts";
await fetchStatus();
parameters:
type StatusOptions = {
state?: "scheduled" | "ongoing" | "completed" | "canceled" | undefined;
};
returns:
type StatusResponse = {
code: "0";
msg: "";
data: {
title: string;
state: string;
begin: number;
end: number;
href: string;
serviceType: "0" | "1" | "2" | "3" | "4" | "5";
system: "classic" | "unified";
scheDesc: string;
}[];
};