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

my-json-server-lib

v1.0.2

Published

This is a npm package for the my-json-server client has the following features:

Readme

My-JSON-Server (Library)

A lightweight TypeScript library to interact with my-json-server via HTTP and WebSocket.
Easily read, write, delete, and listen for real-time changes in your JSON data.

Check out the server repository: my-json-server


Issues

  • The name of the library on the example is wrong
  • Please update the types so it allows both arrays and dicts

Features

  • Simple HTTP API: read, write, and delete JSON data.
  • Real-time updates: WebSocket support to listen for changes.
  • TypeScript friendly: fully typed API for safer code.
  • Node.js support: works seamlessly in modern Node environments.

Installation

npm install my-json-server-lib
# or
yarn add my-json-server-lib

Usage Example

import MyJSON from 'my-json-server-lib';

(async () => {
  const API_TOKEN = 'THIS_IS_A_CLIENT_TOKEN';
  const myJSON = MyJSON.connect('http://localhost:3000/client/test', API_TOKEN);
  // listens for the next change
  myJSON.onChange((updatedData) => {
    console.log('Data changed in real-time:', updatedData);
  });

  // write a new data
  console.log('Creating the data...');
  await myJSON.write({ foo: 'foo' });
  console.log('Data created');

  // gets the data from server
  console.log('Reading data...');
  const data = await myJSON.read();
  console.log('Current data:', data);

  // rewrites the data again.
  data.foo = 'bar';
  await myJSON.write(data);
  console.log('Data updated successfully');
})();

API

MyJSON.connect<T>(baseUrl, token)

Creates a new client instance.

  • baseUrl: API endpoint URL
  • token: authentication token

read(): Promise<T>

Fetches the current JSON data from the server.

write(data: T)

Sends or updates JSON data on the server.

delete()

Deletes the JSON data from the server.

onChange(callback: (data: T) => void)

Listens for real-time updates via WebSocket.

close()

Closes the WebSocket connection.


Contributing

We (me and my dog) welcome contributions! 🛠️

Feel free to open issues, suggest improvements, or submit pull requests. Whether it’s fixing bugs, adding features, or improving documentation, every contribution helps.

Please follow the coding style and best practices used in the library.

Notes

  • The library automatically allows Node.js to exit if no other work is pending (WebSocket uses unref() internally).
  • Supports both TypeScript and JavaScript projects.

License

MIT

Changelog

This version:

  • 1.0.1 - Updated import and export package.json definitions
  • 1.0.1 - MyJSON now accepts dicts and arrays
  • 1.0.1 - Fix name of the libary, updated examples and readme
  • 1.0.0 - Initial implementation