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

api-diff-cli

v1.0.0

Published

Compare API responses and detect changes - perfect for regression testing

Downloads

95

Readme

api-diff-cli

Compare API responses and detect changes — perfect for regression testing.

npm version License: MIT

Zero dependencies. Uses Node.js built-in https module only.


Install

npm install -g api-diff-cli

Or run without installing:

npx api-diff-cli <url1> <url2>

Usage

Compare two API versions

api-diff https://api.example.com/v1/users https://api.example.com/v2/users

Output:

  api-diff-cli v1.0.0

  URL 1: https://api.example.com/v1/users → HTTP 200
  URL 2: https://api.example.com/v2/users → HTTP 200

  + users[2].role: "admin"
  - users[0].legacy_id: 42
  ~ users[1].profile.avatar:
      URL 1: null
      URL 2: "https://cdn.example.com/avatars/2.png"

  Summary: 1 added, 1 removed, 1 changed

Save a baseline snapshot

api-diff --save baseline.json https://api.example.com/users

Compare live response against baseline

api-diff --baseline baseline.json https://api.example.com/users

Ignore volatile fields

api-diff --ignore-keys "updatedAt,timestamp,requestId" \
  https://old.api/data https://new.api/data

POST request comparison

api-diff --method POST --body '{"query":"test"}' \
  https://old.api/search https://new.api/search

Custom headers (auth, etc.)

api-diff --header "Authorization:Bearer mytoken" \
  https://api.example.com/v1/profile https://api.example.com/v2/profile

CI Integration

api-diff exits with code 1 when differences are found — drop it straight into any pipeline.

GitHub Actions

name: API Regression Check

on: [push, pull_request]

jobs:
  api-diff:
    runs-on: ubuntu-latest
    steps:
      - name: Check API for regressions
        run: |
          npx api-diff-cli \
            https://staging.myapp.com/api/users \
            https://prod.myapp.com/api/users

Baseline workflow (recommended for staging deploys)

jobs:
  regression:
    steps:
      # After deploy to staging, compare against prod baseline
      - name: Save production baseline
        run: npx api-diff-cli --save prod-baseline.json https://prod.myapp.com/api/data

      - name: Deploy to staging
        run: ./deploy.sh staging

      - name: Check for regressions
        run: |
          npx api-diff-cli \
            --baseline prod-baseline.json \
            --ignore-keys "timestamp,requestId,serverTime" \
            https://staging.myapp.com/api/data

Pre-commit hook (.git/hooks/pre-push)

#!/bin/bash
echo "Checking API for regressions..."
api-diff \
  --baseline ./test/baseline.json \
  --ignore-keys "updatedAt,cachedAt" \
  https://localhost:3000/api/health || {
    echo "API regression detected! Aborting push."
    exit 1
  }

CircleCI

- run:
    name: API Regression Test
    command: |
      npx api-diff-cli \
        $OLD_API_URL/endpoint \
        $NEW_API_URL/endpoint

Options

| Flag | Description | |------|-------------| | --method <METHOD> | HTTP method (default: GET) | | --body <JSON> | Request body for POST/PUT | | --header <K:V> | Add a request header (repeatable) | | --ignore-keys <k1,k2> | Comma-separated keys to skip in diff | | --baseline <file> | Compare live URL against saved JSON baseline | | --save <file> | Save API response as baseline JSON file | | --no-color | Disable ANSI color output | | --help | Show help |


Exit Codes

| Code | Meaning | |------|---------| | 0 | No differences found (or baseline saved) | | 1 | Differences detected | | 2 | Error (network failure, invalid JSON, etc.) |


Diff Output

The diff engine does a deep recursive comparison of JSON objects and arrays:

  • + green — field added in URL 2 / live response
  • - red — field removed vs URL 1 / baseline
  • ~ yellow — field value changed (shows both old and new)

Paths use dot notation and bracket notation:

users[0].profile.avatar: null → "https://..."
meta.pagination.total: 42 → 43
settings.features.darkMode: false → true

License

MIT © Wilson Xu