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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mc-api-cli

v1.0.4

Published

A beautiful CLI API client with Postman-like features

Readme

mc-api-cli: A Powerful Command-Line Tool for API Requests

mc-api-cli is a versatile command-line interface (CLI) tool designed to simplify API request building, execution, and management. With a sleek browser-based UI, it allows you to construct and send API requests, authenticate with Salesforce orgs, save requests to collections, and view responses in a polished format. Whether you're a developer, tester, or Salesforce administrator, mc-api-cli streamlines your workflow with features like JSON response visualization, cURL command generation, and support for custom ports.

Features

  • Interactive Web UI: Build and send API requests through a modern browser interface
  • Salesforce Authentication: Seamlessly authenticate with Salesforce orgs using the Salesforce CLI (sf) for secure API access.
  • Request Collections: Save and organize API requests into reusable collections stored as JSON.
  • JSON Response Viewer: View JSON responses in a Monaco Editor with syntax highlighting and an "Export JSON" feature.
  • DataTables Support: Display tabular data (CSV or JSON arrays) in an interactive DataTable with export options.
  • cURL Command Generation: Generate and copy cURL commands for requests
  • Custom Port Configuration: Run the UI server on a custom port using the -p option (defaults to 3000).
  • Cross-Platform: Works on macOS, Linux, and Windows with Node.js.

Installation

Install mc-api-cli globally via npm:

npm install -g mc-api-cli

Prerequisites

  • Node.js: Version 14 or higher (node --version to check).
  • Salesforce CLI: Required for Salesforce authentication. Install it from Salesforce CLI.
    npm install @salesforce/cli --global

Usage

mc-api-cli provides three main commands: request, auth, and import. Run mc-api-cli --help for a full list of commands and options.

1. Authenticate with Salesforce

Authenticate with a Salesforce org to enable authenticated API requests.

mc-api-cli auth -u <username> 

Example:

mc-api-cli auth -u username 

Note: Ensure the org is authorized with the Salesforce CLI:

sf force auth web login -r <instanceUrl>

2. Send an API Request

Open a browser-based UI to build and send API requests.

mc-api-cli request [-m <method>] [-u <url>] [-c <collection>] [--header <header...>] [--param <param...>] [-d <data>] [-u <username>] [-p <port>]
  • -m, --method <method>: HTTP method (default: GET).
  • -u, --url <url>: Request URL.
  • -c, --collection <collection>: Collection name to prefill or save the request.
  • --header <header...>: Headers in key:value format (multiple allowed).
  • --param <param...>: Query parameters in key=value format (multiple allowed).
  • -d, --data <data>: Request body as a JSON string.
  • -u, --username <username>: Salesforce org username for authentication.
  • -p, --port <port>: Port for the UI server (default: 3000).

Example:

mc-api-cli request -u https://jsonplaceholder.typicode.com/posts/1 -m GET --header "Accept: application/json" -p 3001

This opens a browser at http://localhost:3001 with a prefilled GET request. The UI allows you to:

  • Modify the request (method, URL, headers, params, body).
  • Select a Salesforce org for authentication.
  • Save the request to a collection.
  • View the response in a Monaco Editor (for JSON), DataTable (for CSV/JSON arrays), or <pre> tag.
  • Copy the equivalent cURL command or export JSON responses.

3. Import a Collection

Import a collection of saved requests from a JSON file.

mc-api-cli import -f <file>
  • -f, --file <file>: Path to the JSON file containing the collection.

Example Collection File (collection.json):

{
  "TestCollection": {
    "name": "TestCollection",
    "requests": [
      {
        "method": "GET",
        "url": "https://jsonplaceholder.typicode.com/posts/1",
        "headers": { "Accept": "application/json" },
        "params": { "userId": "1" },
        "data": null
      }
    ]
  }
}

Import Command:

mc-api-cli import -f ./collection.json

Then load the collection in the UI:

mc-api-cli request -c TestCollection -p 3001

Configuration

  • Authentication Data: Stored in ~/.mc-api-cli/auth.json.
  • Collections: Stored in ~/.mc-api-cli/collections.json.
  • Directory Creation: The ~/.mc-api-cli/ directory is automatically created on first use.

To clear authentication data:

mc-api-cli auth -u <username>  # Re-authenticate
# Or manually delete ~/.mc-api-cli/auth.json

Troubleshooting

  • Salesforce CLI Not Found:

    • Install the Salesforce CLI:
      npm install @salesforce/cli --global
    • Verify with sf --version.
  • No Authorized Orgs Found:

    • Authorize the org:
      sf org login web -a <username>
  • Port in Use:

    • If Port 3000 is already in use, use a different port:
      mc-api-cli request -p 3001
    • Find and kill processes using the port:
      lsof -i :3000
      kill -9 <pid>
  • UI Not Loading:

    • Manually open http://localhost:<port> in your browser.
    • Check console output for errors.
  • Response Issues:

    • JSON responses appear in the Editor with an "Export JSON" button.
    • CSV or JSON array responses display in a DataTable with a CSV export option.