npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

okex-api

v1.0.0-beta.3

Published

A modern, asynchronous, and easy-to-use [Okx API](https://www.okx.com/docs-v5) wrapper for Node.js/bun/Web Browser/Cloudflare workers.

Readme

okex-api

A modern, asynchronous, and easy-to-use Okx API wrapper for Node.js/bun/Web Browser/Cloudflare workers.

This lib is developed by bun, and written in typescript.

Thanks to okx-api, it defines almost all types of apis, and it's good to use. But it uses axios for restful api, ws for websocket api(when useing node), and node:crypto for signature, so it cannot be used in Cloudfalre Workers, that's why i rewrite.

Features

  • Depends nothing.
    • Use fetch api for restful api.
    • Use globalThis.WebScoket for webScoket api(So requires node version >= 22).
    • Use web crypto api for signature.
  • Typscript support.
  • Implements almost all Okx v5 apis.
  • Websocket api with autoreconnect & promisified order op api.
  • Browser support.
  • Cloudflare workers support.

Installation

### Using npm
npm install okex-api

### Using bun
bun install okex-api

Documentation

For restful API, see OKX API Documentation, and find it in HttpApi, you will known how to use.

import { HttpApi } from 'okex-api';
// ...

const api = await HttpApi.create(process.env.API_KEY!, process.env.API_SECRET!, process.env.PASSPHRASE!); // Because web crypto api is async, so we have to create in async function.
console.log(await api.getBalance({ ccy: 'BTC'}));
console.log(await api.getAccountInstruments({ instType: 'SWAP' }));

For websocket API, see OKX API Documentation to find channels you want to subscribe.

import { WsPublic, WsPrivate } from 'okex-api';
// ...

const wsPublic = new WsPublic(); // Public channel.
wsPublic.addEventListener('open', () => {
  console.log('Connected');
  ws.subscribe({ channel: 'tickers', instId: 'ETH-USD-SWAP' });
});

wsPublic.addEventListener('subscribe', (event) => {
  console.log(event.data);
});

wsPublic.addEventListener('tickers', (event) => {
  console.log(event.data);
});

wsPublic.connect();

const wsPrivate = await WsPrivate.create(process.env.API_KEY!, process.env.API_SECRET!, process.env.PASSPHRASE!); // Will auto login & auto connect.
wsPrivate.addEventListener('open', () => {
  console.log('Connected');
  wsPrivate.subscribe({ channel: 'positions', instType: 'SWAP', instFamily: 'ETH-USD' });
});

wsPrivate.addEventListener('login', (event) => {
  console.log(event.data);
});

wsPrivate.addEventListener('positions', (event) => {
  console.log(event.data);
});

wsPrivate.connect();
// Websocket api to plalce order, cancel order, etc.
const order = await wsPrivate.order({ instId: 'ETH-USD-SWAP', tdMode: 'cross', side: 'sell', posSide: 'short', ordType: 'market', sz: '1'});
const ordId = order.data[0].ordId;
await wsPrivate.cancelOrder({ instId: 'ETH-USD-SWAP', ordId });

Abount API credentials

Create API credentials at okx, OKX my-api