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

@migueddev/schwab-client

v1.1.0

Published

Unofficial Schwab API for trading and market data (TypeScript/Node.js)

Readme

📦 @migueddev/schwab-client

Node.js TypeScript License

An unofficial client in Node.js + TypeScript to interact with the Charles Schwab API.
Supports OAuth2 authentication, token auto-refresh, authorization scraping, and access to Trader and Market Data APIs.


✨ Features

  • 🔑 OAuth2 Authentication (Authorization Code + Refresh Token)
  • ♻️ Automatic token refresh
  • 📂 Token persistence in JSON file
  • 🛠 Modular: Clear separation between TraderAPI, MarketDataAPI
  • 🖥 TOTP (2FA) support
  • 🤖 Scraping with Puppeteer to get the authorization_code

📦 Installation

npm install @migueddev/schwab-client

🚀 Usage

Client initialization

import { SchwabClient } from '@migueddev/schwab-client';

(async () => {
  const client = await SchwabClient.init({
    loginId: 'your-login-id',
    password: 'your-password',
    totpSecret: 'your-2fa-secret',
    appKey: 'your-app-key',
    appSecret: 'your-app-secret',
    callbackUrl: 'https://your-callback-url.com',
    tokensFilePath: './tokens.json', // optional
    timeoutMs: 5000, // optional
    enableLogging: true, // optional
    autoRefreshTokens: true, // optional
  });

  // List all linked accounts
  const accounts = await client.trader.getLinkedAccounts();
  console.log(accounts);

  // Get details for a specific account
  const accountDetails = await client.trader.getAccountDetails(
    accounts[0].accountHash,
    { fields: 'positions' },
  );
  console.log(accountDetails);
})();

⚙️ API

The client presents the following main modules:

trader

  • getLinkedAccounts() - Get list of linked account numbers (encrypted)
  • getAccountDetails(accountHash, params) - Get balances and optionally positions for a specific account
  • getAllAccountsDetails(params) - Get balances and optionally positions for all linked accounts
  • getAccountOrders(accountHash, params) - Get orders for a specific account
  • placeOrder(accountHash, orderRequest) - Place a new order for a specific account
  • getOrderDetails(accountHash, orderId) - Get details of a specific order for a specific account
  • cancelOrder(accountHash, orderId) - Cancel a specific order for a specific account
  • replaceOrder(accountHash, orderId, orderRequest) - Replace a specific order for a specific account
  • getAllOrders(params) - Get all orders across all accounts
  • previewOrder(accountHash, previewOrder) - Preview an order before placing it

👪 Contributing

Contributions to @migueddev/schwab-client are always welcome! If you want to contribute:

  1. Follow Conventional Commits: All commit messages should follow the Conventional Commits standard.
  2. Fork the repository and create a branch for your feature or bugfix.
  3. Write clear code and tests: Make sure your code is well-structured, readable, and includes tests where applicable.
  4. Submit a Pull Request (PR): Provide a detailed description of the changes and link any related issues.
  5. Review Process: Your PR will be reviewed and feedback may be provided before merging.

We appreciate your contributions to make @migueddev/schwab-client better!


📜 Licencia

This project is under license MIT.


⚠️ Disclaimer

This is an unofficial Schwab API client. Use at your own risk. Please adhere to Charles Schwab's Terms and Conditions.