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 🙏

© 2025 – Pkg Stats / Ryan Hefner

trading-platform-api

v1.0.0

Published

Unofficial Node.js client for interacting with the trading platform API

Downloads

76

Readme

Trading Platform API

An unofficial Node.js client for interacting with the trading platform API.

Installation

npm install trading-platform-api

Usage

const tradingApi = require('trading-platform-api');

async function main() {
  try {
    // Authenticate (opens a browser for manual login)
    await tradingApi.login();
    
    // Place an order
    const order = await tradingApi.placeOrder({
      symbol: 'BTC/USDT',
      type: 'limit',
      price: 50000,
      amount: 0.1,
      orderType: 'buy'
    });
    
    console.log('Order placed:', order);
    
    // Get open orders
    const openOrders = await tradingApi.getOpenOrders(1, 10, "BTC/USDT");
    console.log('Open orders:', openOrders);
    
    // Get order status
    const status = await tradingApi.getOrderStatus(order.orderId);
    console.log('Order status:', status);
    
    // Get current ticker information
    const ticker = await tradingApi.getCurrentTicker("BTC/USDT");
    console.log('Current ticker:', ticker);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

main();

API Reference

login()

Opens a browser for manual login to the trading platform.

Returns: Promise - Authentication token

logout()

Deletes the saved authentication token.

placeOrder(orderDetails)

Places a new order on the trading platform.

Parameters:

  • orderDetails (Object):
    • coinMarket (string): Trading pair (e.g., "BTC/USDT")
    • type (string): Order type (e.g., "buy", "sell")
    • price (number): Order price
    • amount (number): Order amount
    • orderType (string): Type of order (e.g., "limit", "market")

Returns: Promise - Order response

getOpenOrders(pageNum, pageSize, coinMarket)

Gets open orders from the trading platform.

Parameters:

  • pageNum (number): Page number for pagination
  • pageSize (number): Number of orders per page
  • coinMarket (string): Trading pair (e.g., "BTC/USDT")

Returns: Promise - Open orders data

getOrderStatus(orderId, coinMarket)

Gets status of a specific order.

Parameters:

  • orderId (string): Order ID to check
  • coinMarket (string, optional): Trading pair

Returns: Promise - Order status

getCurrentTicker(coinMarket)

Gets current ticker information for a specific market.

Parameters:

  • coinMarket (string): Trading pair (e.g., "BTC/USDT")

Returns: Promise - Current ticker data

License

MIT


## 6. Test Locally Before Publishing

Before publishing, test your package locally:

```bash
# In your package directory
npm link

# In another project directory
npm link trading-platform-api

7. Publish to NPM

When ready to publish:

# Login to npm
npm login

# Publish the package
npm publish

8. Additional Good Practices

  1. Add TypeScript Definitions: Create a index.d.ts file with type definitions:
declare module 'trading-platform-api' {
  export function login(): Promise<string>;
  export function logout(): void;
  
  export function placeOrder(orderDetails: {
    coinMarket: string;
    type: string;
    price: number;
    amount: number;
    orderType: string;
  }): Promise<any>;
  
  export function getOpenOrders(
    pageNum: number, 
    pageSize: number, 
    coinMarket: string
  ): Promise<any>;
  
  export function getOrderStatus(
    orderId: string, 
    coinMarket?: string
  ): Promise<any>;
  
  export function getCurrentTicker(coinMarket: string): Promise<any>;
  
  export function connectTradesWS(callback: (data: any) => void): any;
}