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

stake-trading

v0.1.0

Published

An unofficial TypeScript SDK for Stake trading platform

Readme

stake-trading

Unofficial TypeScript SDK for the Stake trading APIs (US / NYSE-style routes and ASX). This project is not affiliated with or endorsed by Stake. Stake may change their APIs at any time; use this library at your own risk and review Stake’s terms of use.

Features

  • Typed requests and responses (Zod schemas + TypeScript types)
  • Promise-based StakeClient with sub-clients (orders, watchlist, equities, …)
  • NYSE (US) and ASX exchange configurations with shared patterns where possible
  • Structured logging via Winston (LOG_LEVEL env var)

Requirements

  • Node.js 20+

Installation

yarn add stake-trading

or

npm install stake-trading

Quick start

Session token

import StakeClient, { SessionTokenLoginRequestSchema } from 'stake-trading';
import { NYSE } from 'stake-trading';

const loginRequest = SessionTokenLoginRequestSchema.parse({
  token: process.env.STAKE_TOKEN!,
});

const client = new StakeClient(loginRequest, NYSE);
await client.login(loginRequest);

const orders = await client.orders.list();

Credentials (creates a session via Stake’s login API)

Environment variables STAKE_USER, STAKE_PASS, and optionally STAKE_PLATFORM_TYPE / STAKE_TOKEN are read by the Zod schemas when fields are omitted.

import StakeClient, { CredentialsLoginRequestSchema } from 'stake-trading';
import { NYSE } from 'stake-trading';

const loginRequest = CredentialsLoginRequestSchema.parse({});
const client = new StakeClient(loginRequest, NYSE);
await client.login(loginRequest);

ASX

import StakeClient, { SessionTokenLoginRequestSchema } from 'stake-trading';
import { ASX } from 'stake-trading';

const loginRequest = SessionTokenLoginRequestSchema.parse({ token: '...' });
const client = new StakeClient(loginRequest, ASX);
await client.login(loginRequest);

NYSE-only clients (e.g. fx, ratings, statements) are omitted when using ASX.

API shape

The client is organized by domain, not by a single flat placeOrder / getAccount surface:

| Area | Client accessor | Examples | | ---------- | ------------------ | ------------------------------------------ | | Orders | client.orders | list(), cancel(...), brokerage(...) | | Watchlists | client.watchlist | listWatchlists(), watchlist({ id }), … | | Products | client.products | get(...), search({ keyword }) | | Equities | client.equities | list() | | Trades | client.trades | (see src/trade.ts) | | … | … | Explore src/*.ts and src/asx/ |

Base URLs and paths live in constant.ts (NYSE, ASX).

Error handling

  • InvalidLoginException — failed credential login or invalid session when loading the user profile (extends AuthenticationError).
  • StakeHttpError — non-2xx HTTP response (statusCode, statusText, optional responseBody).
  • StakeError — base class; also ValidationError, RateLimitError, OrderError, NetworkError, etc. for app-level use.
import {
  StakeClient,
  InvalidLoginException,
  StakeHttpError,
} from 'stake-trading';

try {
  await client.login(request);
} catch (e) {
  if (e instanceof InvalidLoginException) {
    // bad credentials or session
  } else if (e instanceof StakeHttpError) {
    console.error(e.statusCode, e.responseBody);
  }
}

Zod may throw ZodError if API responses no longer match the packaged schemas.

Logging

The SDK uses a shared Winston logger (see src/logging.ts). Set LOG_LEVEL to debug, info, etc. POST bodies are never logged, so passwords and tokens are not written by the debug logger.

import { logger } from 'stake-trading';

logger.info('Application message');

Manual smoke test (maintainers)

With STAKE_TOKEN set and network access:

yarn example:session

Development

yarn install
yarn build
yarn test
yarn run check   # lint + format check + tests

See TESTING.md and PUBLISHING.md for more detail.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Run yarn run check before opening a PR

License

MIT — see LICENSE.

Issues

Report problems on GitHub Issues.