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

5paisa-ts-sdk

v1.0.0

Published

Modern TypeScript SDK for 5paisa Trading APIs

Readme

5paisa TypeScript SDK

A modern, lightweight, TypeScript-first SDK for interacting with 5paisa Trading APIs. Designed for Node.js 18+, with strong typing, modular services, and zero deprecated dependencies.


✨ Features

  • ✅ TypeScript-first with .d.ts support
  • ✅ No deprecated libraries (axios, request, node-pandas removed)
  • ✅ Clean service-based API (auth, orders, market)
  • ✅ Native fetch (Node.js 18+)
  • ✅ Safe payload builders (no shared mutable state)
  • ✅ GitHub & npm install support

📦 Installation

From GitHub (recommended during development)

npm install git+https://github.com/AmitManna99/5paisa-ts-sdk.git

From npm (once published)

npm install 5paisa-ts-sdk

⚙️ Requirements


🚀 Quick Start

1️⃣ Create Client

import { FivePaisaClient } from "5paisa-ts-sdk";

const client = new FivePaisaClient({
  appName: "my-app",
  userId: "YOUR_USER_ID",
  password: "YOUR_PASSWORD",
  userKey: "YOUR_VENDOR_KEY",
  encryptionKey: "YOUR_ENCRYPTION_KEY",
  clientCode: "YOUR_CLIENT_CODE",
  appSource: 1234,
});

🔐 Authentication

Option 1: Login using TOTP + PIN

const requestToken = await client.auth.getRequestToken("TOTP_CODE", "PIN");

await client.auth.getAccessToken(requestToken);

// Client is now authenticated

Option 2: Login using Access Token (recommended for automation)

await client.auth.setAccessToken("EXISTING_ACCESS_TOKEN");

Option 3: OAuth Login (Browser Flow)

  1. Redirect user to:
https://dev-openapi.5paisa.com/WebVendorLogin/VLogin/Index
  ?VendorKey=<YOUR_USER_KEY>
  &ResponseURL=<YOUR_REDIRECT_URL>
  1. Extract RequestToken from redirect URL
  2. Exchange it for access token:
await client.auth.getAccessToken(requestToken);

📊 Holdings & Positions

Fetch Holdings

const holdings = await client.orders.getHoldings();
console.log(holdings);

Fetch Positions

const positions = await client.orders.getPositions();
console.log(positions);

🧾 Orders

Place Order

await client.orders.placeOrder({
  scripCode: 1660,
  qty: 1,
  orderType: "BUY",
  exchange: "N",
  price: 208,
});

Modify Order

await client.orders.modifyOrder({
  exchangeOrderID: "1100000007628729",
  qty: 1,
  price: 210,
  exchange: "N",
  exchangeType: "C",
  isIntraday: false,
});

Cancel Order

await client.orders.cancelOrder("1100000007973827");

🧠 BO / CO Orders

Place BO-CO Order

await client.orders.placeBOCOOrder({
  scripCode: 1660,
  qty: 1,
  limitPrice: 205,
  triggerPrice: 0,
  targetPrice: 217,
  side: "BUY",
  exchange: "N",
  exchangeType: "C",
});

Modify BO-CO Order (Profit / SL Leg)

await client.orders.modifyBOCOOrder({
  exchOrderId: "1100000008697274",
  price: 215,
});

📈 Market Data

Market Feed

const feed = await client.market.getMarketFeed([
  {
    Exch: "N",
    ExchType: "D",
    Symbol: "NIFTY 27 MAY 2021 CE 14500.00",
    Expiry: "20210527",
    StrikePrice: "14500",
    OptionType: "CE",
  },
]);

console.log(feed);

Market Feed by Scrip

const feed = await client.market.getMarketFeedByScrip([
  {
    Exch: "N",
    ExchType: "C",
    ScripCode: 1660,
    ScripData: "RELIANCE_EQ",
  },
]);

Market Depth

const depth = await client.market.getMarketDepth([
  { Exchange: "N", ExchangeType: "C", ScripCode: 1660 },
]);

⏱ Historical Data

const candles = await client.market.getHistoricalData({
  exchange: "N",
  exchangeType: "C",
  scripCode: 1660,
  timeframe: "1m",
  from: "2021-05-31",
  to: "2021-06-01",
});

Supported timeframes:

['1m', '5m', '10m', '15m', '30m', '60m', '1d']

📚 API Structure Overview

client.auth; // authentication & tokens
client.orders; // holdings, orders, positions
client.market; // market feed, depth, historical data

🛡️ Notes & Best Practices

  • Always store access tokens securely
  • Prefer access-token login for long-running services
  • SDK expects Node.js 18+
  • This SDK does not manage retries / rate limits yet

🧪 Development

npm run dev

📄 License

MIT


🚧 Roadmap

  • Typed API responses
  • Runtime validation (Zod)
  • Retry & rate-limit handling
  • WebSocket feed support
  • npm public release