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

json-sdk

v0.3.4

Published

TypeScript client for json-server — self-hosted REST API platform

Readme

json-sdk

TypeScript client for json-server — turn JSON files into REST APIs.

npm install json-sdk

Quick Start

Paths use /username/filename format since each user's files are namespaced under their GitHub username. Both "/username/file" and "username/file" are accepted — the SDK normalizes them.

import { JsonSDK } from "json-sdk"

const api = new JsonSDK({
  baseUrl: "https://json.shahriyar.dev",
  apiKey: "your-api-key", // required for private files and writes
})

// Fetch products with query params
const products = await api.get("/shahriyar/products", {
  filter: { categoryId: "1" },
  sort: "price",
  order: "desc",
  limit: 10,
})

Methods

get<T>(path, params?)

Fetch data. Optionally filter, sort, search, and paginate.

const products = await api.get("/alice/products")
const users = await api.get<User[]>("/alice/users", { search: "john" })
const comments = await api.get("/alice/posts/1/comments")

| Param | Type | Description | |-------|------|-------------| | search | string | Search across all string values | | filter | Record<string, string> | Filter by exact key:value match | | sort | string | Field to sort by | | order | "asc" \| "desc" | Sort direction | | limit | number | Maximum results | | start | number | Slice start index | | end | number | Slice end index | | skip | number | Skip N results |

post<T>(path, body)

Add an item to an array. Requires auth.

const product = await api.post("/alice/products", {
  name: "Phone",
  price: 599,
})

patch<T>(path, body, params?)

Update items by ID segment or with filters. Requires auth.

// Update by ID
await api.patch("/alice/products/1", { price: 499 })

// Update matching items
await api.patch("/alice/products", { inStock: false }, {
  filter: { stock: "0" },
})

del<T>(path, params?)

Delete items by ID segment or with filters. Requires auth.

// Delete by ID
await api.del("/alice/products/1")

// Delete matching items
await api.del("/alice/products", { filter: { status: "archived" } })

TypeScript

All methods accept a type parameter for type-safe responses.

type Product = { id: number; name: string; price: number }

const products = await api.get<Product[]>("/alice/products")
const product = await api.post<Product>("/alice/products", {
  name: "Headphones",
  price: 199,
})

Error Handling

import { JsonSDK, ApiError } from "json-sdk"

const api = new JsonSDK({ baseUrl: "https://json.shahriyar.dev" })

try {
  await api.get("/alice/products")
} catch (err) {
  if (err instanceof ApiError) {
    console.log(`HTTP ${err.status}: ${err.message}`)
  }
}

Auth

Pass an API key in the constructor:

const api = new JsonSDK({
  baseUrl: "https://json.shahriyar.dev",
  apiKey: "key_abc123",
})

The key is sent via Authorization: Bearer header. You can also pass it as ?api_key= query param. Required for private files and all write operations (POST, PATCH, DELETE).

License

MIT