Catalog npm
PACKAGE EXPLORERView in registry

5paisa-ts-sdk

npm

Modern TypeScript SDK for 5paisa Trading APIs

5paisaalgo-tradingbroker-sdknodejstrading-apitypescript
Versions collected1
Direct dependencies4From release 1.0.0
Last observed20 Oct, 20:38 UTC

README

Current package documentation

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

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

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

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.0Registry latest24 Jan 20264

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
amitmanna99/5paisa-ts-sdk

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:38 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:15544fbefc577b34f65c8c0ea69a1e8a3278af6a0b1a90667b5d175473fe333e