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

@mstock-mirae-asset/nodetradingapi-typeb

v0.0.2

Published

The official TypeScript/JavaScript client for mStock TypeB Trading API

Readme

TradingAPI TypeB TypeScript/JavaScript SDK

npm version License: MIT Node.js Version

The official TypeScript/JavaScript client for communicating with the TypeB Trading API.

mStock TypeB is a comprehensive trading API that provides capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (WebSockets), and more.

Documentation

Requirements

  • Node.js v18.0.0+

Installation

Install via npm

npm install @mstock-mirae-asset/nodetradingapi-typeb

Features

  • Comprehensive API Coverage - Full support for all TypeB trading API endpoints
  • TypeScript Support - Fully typed with TypeScript for better development experience
  • Authentication - Built-in support for JWT token authentication
  • Order Management - Place, modify, cancel orders with ease
  • Portfolio Management - View positions, holdings, and trade history
  • Market Data - Real-time quotes, historical data, and chart data
  • Basket Orders - Create and manage basket orders
  • Options Trading - Complete options chain support
  • Error Handling - Comprehensive error handling and retry mechanisms

Getting started with API

Basic Setup

import { MConnect } from '@mstock-mirae-asset/nodetradingapi-typeb';

// Initialize the client
const client = new MConnect('https://api.mstock.trade', 'your-api-key');

// Login
const loginResponse = await client.login({
    clientcode: 'your-client-code',
    password: 'your-password',
    totp: 'your-totp',
    state: 'your-state'
});

// Set access token
client.setAccessToken(loginResponse.data.jwtToken);

Place an Order

const order = await client.placeOrder({
    variety: 'NORMAL',
    tradingsymbol: 'INFY',
    symboltoken: '1594',
    exchange: 'NSE',
    transactiontype: 'BUY',
    ordertype: 'LIMIT',
    quantity: '100',
    producttype: 'DELIVERY',
    price: '1500'
});

Authentication

The SDK supports JWT token authentication. After successful login, use the setAccessToken method to set the authentication token.

const loginResponse = await client.login({
    clientcode: 'your-client-code',
    password: 'your-password',
    totp: 'your-totp',
    state: 'your-state'
});

client.setAccessToken(loginResponse.data.jwtToken);

Usage Examples

Order Management

// Place an order
const order = await client.placeOrder({
    variety: 'NORMAL',
    tradingsymbol: 'INFY',
    symboltoken: '1594',
    exchange: 'NSE',
    transactiontype: 'BUY',
    ordertype: 'LIMIT',
    quantity: '100',
    producttype: 'DELIVERY',
    price: '1500'
});

// Modify an order
const modifiedOrder = await client.modifyOrder({
    variety: 'NORMAL',
    orderid: '123456',
    tradingsymbol: 'INFY',
    symboltoken: '1594',
    exchange: 'NSE',
    ordertype: 'MARKET',
    quantity: '50',
    producttype: 'DELIVERY'
});

// Cancel an order
await client.cancelOrder({
    variety: 'NORMAL',
    orderid: '123456'
});

Portfolio Management

// Get positions
const positions = await client.getPositions();

// Get holdings
const holdings = await client.getHoldings();

// Get fund summary
const fundSummary = await client.getFundSummary();

Market Data

// Get historical data
const historicalData = await client.getHistoricalData({
    exchange: 'NSE',
    symboltoken: '1594',
    interval: 'ONE_MINUTE',
    fromdate: '2024-01-01',
    todate: '2024-01-31'
});

// Get real-time quotes
const quotes = await client.getQuote({
    mode: 'FULL',
    exchangeTokens: {
        NSE: ['1594', '2885'],
        BSE: ['500325', '500209']
    }
});

Basket Orders

// Create basket
const basket = await client.createBasket({
    BaskName: 'MyStrategy',
    BaskDesc: 'My trading strategy basket'
});

// Calculate basket
const calculation = await client.calculateBasket({
    basket_name: 'MyStrategy',
    basket_id: '123',
    operation: 'CALCULATE',
    include_exist_pos: 'Y'
});

API Reference

Authentication

| Method | Description | |--------|-------------| | login() | User authentication | | verifyOTP() | Verify OTP for session token | | verifyTOTP() | Verify TOTP for 2FA | | logout() | User logout |

Order Management

| Method | Description | |--------|-------------| | placeOrder() | Place new orders | | modifyOrder() | Modify existing orders | | cancelOrder() | Cancel orders | | cancelAllOrders() | Cancel all open orders |

Portfolio Operations

| Method | Description | |--------|-------------| | getPositions() | Get open positions | | getHoldings() | Get portfolio holdings | | getFundSummary() | Get fund summary |

Market Data

| Method | Description | |--------|-------------| | getHistoricalData() | Get historical candlestick data | | getIntradayChartData() | Get intraday chart data | | getQuote() | Get real-time quotes | | getInstrumentMaster() | Get instrument master data |

Options Trading

| Method | Description | |--------|-------------| | getOptionChainMaster() | Get option chain master data | | getOptionChain() | Get detailed option chain data |

Testing

npm test

Building

npm run build

License

MIT License - see LICENSE file for details.

mStock By Mirae Asset Capital Markets (India) Pvt. Ltd. (c) 2025. Licensed under the MIT License.

Support

For issues, please open an issue on GitHub.

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a new branch (feature-xyz)
  3. Commit your changes
  4. Push the branch and create a pull request