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

@glitchmarkets/sdk

v0.4.0

Published

The Glitch API for TypeScript and JavaScript: typed requests, safe retries, trade helpers and a resuming stream.

Readme

@glitchmarkets/sdk

The official JavaScript and TypeScript client for the Glitch API. Use it to read MetaTrader 5 accounts, place and manage trades, and follow prices and positions live, from Node.js, Deno, Bun or the browser.

npm install @glitchmarkets/sdk

Needs Node.js 22 or later. The package is ESM only and ships its own types.

Place a trade

Create an API key on the Developers page in Glitch. A sandbox key trades demo accounts only, so start with one.

import { Glitch, GlitchError } from "@glitchmarkets/sdk";

const glitch = new Glitch({ apiKey: process.env.GLITCH_API_KEY! });

try {
  const result = await glitch.trading("acct_...").market({
    symbol: "EURUSD",
    side: "buy",
    volume: "0.10",
    stopLoss: "1.08340",
    wait: true, // wait up to 10 seconds for the broker's answer
  });
  console.log(result.status);
} catch (error) {
  if (error instanceof GlitchError) console.error(error.code, error.detail);
  else throw error;
}

Prices and volumes are strings, so no decimal is ever rounded on the way.

glitch.trading(accountId) also has preview, close, modify and cancel.

Call any endpoint

glitch.api has one typed call for every documented endpoint, with editor completion for paths, parameters and answers:

const { data, error } = await glitch.api.GET("/accounts/{account_id}", {
  params: { path: { account_id: "acct_..." } },
});

The types for every request and answer are exported as components and paths.

Follow events live

const stream = glitch.stream(["account.acct_....positions"]);
for await (const event of stream) {
  if (event.type === "resync_required") {
    // reload this channel over the REST API, then carry on
  } else {
    console.log(event.channel, event.seq, event.data);
  }
}

The stream reconnects by itself and picks up after the last event it gave you, so nothing is missed or repeated. stream.close() ends it.

Safe retries

Network errors and answers 429, 502, 503 and 504 are sent again, up to maxRetries times (3 by default). Every change carries one Idempotency-Key across its retries, so a trade is placed at most once. Pass your own idempotencyKey to a trade to keep it safe across restarts of your program too.

Errors

A refused request throws GlitchError with the HTTP status, the API's stable code (such as INSUFFICIENT_MARGIN), a readable detail and the requestId to quote to support. Branch on code, never on detail.

Let traders use your app

If your app acts for other traders, ask each one to allow it. First get a client ID: in the Glitch app, open Developers, choose your app and fill in Let traders use your app. If your app has its own server, pick "It has its own server" to get a client secret too, shown once; your server sends it when it swaps the code for tokens. Add the page traders come back to as a redirect address.

In the browser, allowOnGlitch opens Glitch's allow screen in a popup, where the trader signs in and picks what your app may do. Your page never sees their password.

import { allowOnGlitch } from "@glitchmarkets/sdk";

button.onclick = async () => {
  const allowed = await allowOnGlitch({
    clientId: "appc_...",
    redirectUri: "https://your.app/glitch-allowed",
    scope: ["trade"],
  });
  // Send allowed.code, allowed.codeVerifier and allowed.redirectUri to your
  // backend, which trades them for tokens at POST /oauth/token.
};

Call it from a click, or the browser blocks the popup. For React Native, use @glitchmarkets/connect-react-native.

More