
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@teamshooks/mctypea
Advanced tools
The official TypeScript/JavaScript client for communicating with the MConnect TypeA Trading API.
MConnect TypeA 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.
Install via npm
npm install mconnecttypea
import { MConnect } from 'mconnecttypea';
const apiKey = "your_api_key";
const username = "your_username";
const password = "your_password";
const client = new MConnect({ api_key: apiKey });
async function init() {
try {
await authenticateUser();
await getPortfolio();
} catch (err) {
console.error(err);
}
}
async function authenticateUser() {
try {
// Step 1: Login (triggers OTP)
const loginResponse = await client.login({ username, password });
console.log('Login successful, OTP sent');
// Step 2: Get OTP from user input
const otp = "123456"; // Get from user input
// Step 3: Generate session with OTP
const sessionData = await client.generateSession({
api_key: apiKey,
request_token: otp,
checksum: 'W'
});
client.setAccessToken(sessionData.access_token);
console.log('Session generated:', sessionData);
} catch (err) {
console.error('Authentication failed:', err);
}
}
async function getPortfolio() {
try {
const positions = await client.getNetPositions();
const holdings = await client.getHoldings();
const funds = await client.getFundSummary();
console.log('Positions:', positions);
console.log('Holdings:', holdings);
console.log('Funds:', funds);
} catch (err) {
console.error('Error getting portfolio:', err);
}
}
// Initialize the API calls
init();
import { MTicker } from 'mconnecttypea';
const apiKey = "your_api_key";
const accessToken = "generated_access_token";
const ticker = new MTicker({
api_key: apiKey,
access_token: accessToken
});
ticker.connect();
// Set up event handlers
ticker.onBroadcastReceived = onTicks;
ticker.onConnect = subscribe;
ticker.onClose = onDisconnect;
ticker.onError = onError;
ticker.onOrderTradeReceived = onOrderUpdate;
function onTicks(tick: any): void {
console.log('Market data:', {
token: tick.InstrumentToken,
price: tick.LastPrice,
mode: tick.Mode
});
}
function subscribe(): void {
ticker.sendLoginAfterConnect();
const tokens = [5633, 2885]; // Instrument tokens
ticker.subscribe(tokens);
ticker.setMode('full', tokens);
}
function onDisconnect(): void {
console.log('WebSocket disconnected');
}
function onError(error: any): void {
console.log('WebSocket error:', error);
}
function onOrderUpdate(order: any): void {
console.log('Order update:', order);
}
// Place an order
const orderParams = {
exchange: "NSE",
tradingsymbol: "RELIANCE",
transaction_type: "BUY",
quantity: 1,
product: "CNC",
order_type: "LIMIT",
price: 2500,
validity: "DAY",
variety: "regular"
};
const orderResponse = await client.placeOrder(orderParams);
console.log('Order placed:', orderResponse);
// Modify an order
const modifyParams = {
order_id: "ORDER123",
variety: "regular",
quantity: 2,
price: 2600,
order_type: "LIMIT"
};
const modifyResponse = await client.modifyOrder(modifyParams);
console.log('Order modified:', modifyResponse);
// Cancel an order
const cancelResponse = await client.cancelOrder("ORDER123");
console.log('Order cancelled:', cancelResponse);
// Get order book
const orderBook = await client.getOrderBook();
console.log('Order book:', orderBook);
Method | Description |
---|---|
login() | Login with username/password |
generateSession() | Generate session with OTP |
verifyTOTP() | Verify TOTP |
logout() | Logout |
Method | Description |
---|---|
placeOrder() | Place new order |
modifyOrder() | Modify existing order |
cancelOrder() | Cancel order |
getOrderBook() | Get order book |
orderMargin() | Calculate order margin |
Method | Description |
---|---|
getFundSummary() | Get fund summary |
getNetPositions() | Get positions |
getHoldings() | Get holdings |
convertPosition() | Convert position |
Method | Description |
---|---|
getInstruments() | Get instruments master |
getOHLC() | Get OHLC data |
getLTP() | Get last traded price |
getHistoricalCandleData() | Historical data |
loserGainer() | Top gainers/losers |
The SDK includes real-time WebSocket streaming capabilities for live market data and order updates.
ws
: WebSocket client library@types/ws
: TypeScript definitions for WebSocket# Run WebSocket streaming tests
npm run websocket
# Run REST API tests
npm run test
import { MTicker } from 'mconnecttypea';
const ticker = new MTicker({
api_key: "your_api_key",
access_token: "your_access_token"
});
// Connect to WebSocket
ticker.connect();
// Event handlers
ticker.onConnect = () => {
console.log('WebSocket connected');
ticker.sendLoginAfterConnect();
// Subscribe to instruments
const tokens = [2885, 5633]; // RELIANCE, HDFCBANK
ticker.subscribe(tokens);
ticker.setMode('full', tokens);
};
ticker.onBroadcastReceived = (tick) => {
console.log('Market data:', {
token: tick.InstrumentToken,
ltp: tick.LastPrice,
volume: tick.Volume
});
};
ticker.onOrderTradeReceived = (order) => {
console.log('Order update:', order);
};
ticker.onError = (error) => {
console.error('WebSocket error:', error);
};
ticker.onClose = () => {
console.log('WebSocket disconnected');
};
In a typical web application where a new instance of views, controllers etc. are created per incoming HTTP request, you will need to initialise a new instance of MConnect client per request as well. This is because each individual instance represents a single user that's authenticated.
Hence, in your web application, typically:
login()
method to trigger OTPgenerateSession()
to obtain the access_token
along with authenticated user dataaccess_token
to initialise instances of MConnect client for subsequent API calls.Check the test files for detailed examples:
MIT License - see LICENSE file for details.
MConnect Technology (c) 2025. Licensed under the MIT License.
FAQs
The official TypeScript/JavaScript client for MConnect TypeA Trading API
We found that @teamshooks/mctypea demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.