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

@znjy/sdk

v0.1.3

Published

TypeScript SDK for ZNJY services.

Readme

@znjy/sdk

TypeScript SDK for ZNJY services.

The first supported module is marketData, which wraps the standalone ZNJY market-data HTTP service.

Documentation

Install

npm install @znjy/sdk

Browser Usage

Browser clients must not receive MARKET_DATA_SERVICE_TOKEN. Use browser clients for public read operations only.

import { ZnjyClient } from "@znjy/sdk";

const znjy = new ZnjyClient({
  baseUrl: "https://market-data.example.com",
});

const prices = await znjy.marketData.getPrices(["600000", "000001"]);
const matches = await znjy.marketData.searchStocks("浦发");
const sources = await znjy.marketData.getSourceStatus();
const market = await znjy.marketData.getMarketStatus();
const indices = await znjy.marketData.getIndices();
const indexKlines = await znjy.marketData.getIndexKlines({ codes: ["000001", "000300"], days: 250 });
const discovery = await znjy.marketData.getDiscovery("merged");
const global = await znjy.marketData.getInsight("global-market");

Server Usage

Use the service token only from server-side code such as API routes, workers, cron jobs, or backend services.

import { ZnjyClient } from "@znjy/sdk";

const znjy = new ZnjyClient({
  baseUrl: process.env.MARKET_DATA_BASE_URL!,
  serviceToken: process.env.MARKET_DATA_SERVICE_TOKEN!,
});

await znjy.marketData.syncSubscriptions({
  source: "manual",
  sourceRef: "portfolio-a",
  replaceSourceRef: true,
  items: [{ code: "600000", name: "浦发银行", market: "cn-a", priority: 100 }],
});

await znjy.marketData.refreshPrices();
await znjy.marketData.refreshSources({ codes: ["600000", "000001"], days: 60 });
await znjy.marketData.refreshInsights({ datasets: ["indices", "breadth"] });
await znjy.marketData.refreshIndexKlines({ codes: ["000001", "000300"], days: 250 });
await znjy.marketData.refreshDiscovery({ datasets: ["merged"] });

Recommended browser-to-admin flow:

Browser
  -> your backend/API route
    -> ZnjyClient with serviceToken
      -> market-data service

Market Data API

Browser-safe methods:

await znjy.marketData.getPrices(["600000", "000001"]);
await znjy.marketData.getPrices();
await znjy.marketData.searchStocks("浦发");
await znjy.marketData.getSourceStatus();
await znjy.marketData.getMarketStatus();
await znjy.marketData.getIndices();
await znjy.marketData.getIndexKlines({ codes: ["000001", "000300"], days: 250 });
await znjy.marketData.getDiscovery("merged");
await znjy.marketData.getCapitalFlow({ codes: ["600000", "000001"] });
await znjy.marketData.getKline("600000", 60);

Privileged methods require serviceToken:

await znjy.marketData.listSubscriptions({ active: "all", limit: 100 });
await znjy.marketData.syncSubscriptions({ source: "manual", items: [] });
await znjy.marketData.refreshPrices();
await znjy.marketData.refreshSources({ codes: ["600000", "000001"] });
await znjy.marketData.refreshInsights({ datasets: ["capital-flow"], codes: ["600000"] });
await znjy.marketData.refreshIndexKlines({ codes: ["000001", "000300"] });
await znjy.marketData.refreshDiscovery({ datasets: ["oversold", "bluechips", "merged"] });

listSubscriptions is intentionally treated as privileged by the SDK because subscription lists can reveal watchlists, portfolios, or internal source references.

Errors

import { ZnjyAuthError, ZnjyHttpError, ZnjyNetworkError } from "@znjy/sdk";

try {
  await znjy.marketData.refreshPrices();
} catch (err) {
  if (err instanceof ZnjyAuthError) {
    // Missing serviceToken for a privileged operation.
  } else if (err instanceof ZnjyHttpError) {
    console.error(err.status, err.code, err.message);
  } else if (err instanceof ZnjyNetworkError) {
    console.error(err.message);
  }
}

Development

bun install
bun test
bun run check
bun run build
npm pack --dry-run

Release

Dry-run the release flow without publishing:

bun run release:dry-run

Dry-run temporarily bumps the package version while npm builds the dry-run tarball, then restores package.json.

Publish a new patch version to npm:

bun run release

The release script runs tests, type-checking, bumps package.json from x.y.z to x.y.(z+1), rebuilds dist, then runs:

npm publish --access public --tag latest

Security

Never expose MARKET_DATA_SERVICE_TOKEN in browser bundles, mobile apps, public repositories, or client-side environment variables. Keep privileged calls on your server.