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

@indexsupply/indexsupply.js

v2.0.3

Published

A Typescript wrapper for Index Supply's API

Downloads

4,519

Readme

indexsupply.js

A Typescript wrapper for Index Supply's API.

Usage

This package is available on NPM.

npm i @indexsupply/indexsupply.js

Single Query

Make a one-time query to get historical data:

import { query } from "@indexsupply/indexsupply.js";

const { cursor, rows } = await query({
  apiKey: "face",
  chainId: 8453,
  query: 'select "from", "to", value from transfer limit 1',
  signatures: ['Transfer(address indexed from, address indexed to, uint256 value)'],
  formatRow: ([from, to, value]) => ({
    from: from as Address,
    to: to as Address,
    value: BigInt(value),
  }),
})

console.log(`Block ${cursor}:`, rows)

Live Query

Subscribe to new data as it arrives:

import { queryLive } from "@indexsupply/indexsupply.js";

const q = queryLive({
  apiKey: "face",
  chainId: 8453,
  startBlock: async () => 1234567n,
  query: 'select "from", "to", value from transfer limit 1',
  signatures: ['Transfer(address indexed from, address indexed to, uint256 value)'],
  formatRow: ([from, to, value]) => ({
    from: from as Address,
    to: to as Address,
    value: BigInt(value),
  }),
})

for await (const { cursor, rows } of q) {
  console.log(`New data at block ${cursor}:`, rows)
}

queryLive will call startBlock each time a new connection to the server is established. If the connection is restarted then queryLive will automatically restablish the connection and will call startBlock to ensure we resume at the correct block height.

A common pattern for startBlock is to use your database to figure out the last block you've processed. For example:

const liveQuery = queryLive({
  startBlock: async () => {
    const rows = await pg.query("select max(block_num) block_num from my_table");
    return BigInt(rows[0].block_num);
  },
  ...
});
for await (const { cursor, rows } of liveQuery) {
  await pg.query("insert into my_table(block_num, ...) values (blockNumber, ...)");
}

See the examples/save-to-postgres source for a complete example.

Using Hosted Package in the Browser

See this page for a working demonstration.

<html>
    <head>
        <script src="https://static.indexsupply.net/indexsupply.js" type="module"></script>
    </head>
    <script type="module">
        import { query } from "https://static.indexsupply.net/indexsupply.js";
        const { cursor, rows } = await query({
            chainId: 8453n,
            signatures: [],
            query: "select block_num from logs limit 1",
        });
        document.querySelector("body pre").textContent = JSON.stringify({ cursor, rows});
    </script>
    <body>
        <pre></pre>
    </body>
</html>

Local Development Setup

% node --version
v22.12.0

% npm run example

> @indexsupply/[email protected] example
> npx tsx examples/live.ts

{
  tx: '0x3f6664da84f4cc2f3bbfd5b9968ea0c06c4d89b682c920ee240f13d9824cbabf',
  block: 23815441n
}