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

greenatomy-sdk

v0.2.5

Published

Lightweight Node.js SDK for Greenatomy logs and stats APIs.

Downloads

801

Readme

Greenatomy SDK

Lightweight Node.js SDK for the Greenatomy logs and stats APIs.

Install

npm install greenatomy-sdk

For local development from this repository:

npm install ./greenatomy-sdk

If you are working inside the SDK folder directly:

npm install

Usage

const GreenatomyClient = require("greenatomy-sdk");

const client = new GreenatomyClient({
  baseUrl: "https://greenatomy-1.onrender.com",
  apiKey: "ga_live_your_project_key",
  timeout: 8000,
});

For your production deployment, use the backend URL on Render: https://greenatomy-1.onrender.com.

You can authenticate with either:

  • apiKey (x-api-key): Recommended for project-specific telemetry ingestion from production/staging/development apps
  • token (Authorization: Bearer <token>): Recommended for authenticated dashboard, user, and project management routesreads

You can also override the default request timeout of 5000 ms with timeout.

Current SDK scope:

  • getLogs()
  • createLog()
  • getStats()
  • getSummary()
  • greenatomyMiddleware()

API

getLogs(params?)

Fetches log entries from GET /logs.

const logs = await client.getLogs({
  page: 1,
  limit: 20,
});

createLog(payload)

Creates a telemetry log via POST /logs.

const createdLog = await client.createLog({
  method: "GET",
  path: "/api/users",
  statusCode: 200,
  durationMs: 142,
  cpuUsedMs: 38.5,
});

Common payload fields:

  • method (required)
  • path (required)
  • statusCode (optional)
  • durationMs (required)
  • cpuUsedMs (optional, defaults to 0)
  • createdAt (optional)

energyKwh, cost, and cpuUtil are calculated by the backend collector and returned in the stored log.

greenatomyMiddleware(options)

Express-style middleware for automatic inbound request telemetry.

const express = require("express");
const GreenatomyClient = require("greenatomy-sdk");
const { greenatomyMiddleware } = GreenatomyClient;

const app = express();

app.use(
  greenatomyMiddleware({
    baseUrl: "https://greenatomy-1.onrender.com",
    apiKey: "ga_live_project_environment_key",
    environment: "production",
  });
);

By default the middleware:

  • tracks every inbound request except OPTIONS
  • measures wall-clock request duration
  • sends method, path, statusCode, durationMs, and createdAt
  • never blocks the user request if telemetry submission fails
  • associates logs with the issuing project API key
  • tags logs by environment (development, staging, production)

Optional middleware options:

  • shouldTrack(req, res) to selectively skip requests
  • onError(error, req, res) to observe telemetry transport failures
  • timeout to override the default request timeout

getStats(params?)

Fetches aggregated log stats from GET /logs/stats.

const stats = await client.getStats();

getSummary(params?)

Fetches a lightweight deployment-ready overview from GET /logs/summary.

const summary = await client.getSummary({ range: "24h" });

Error Handling

The SDK throws GreenatomySdkError for HTTP, timeout, and network failures.

const GreenatomyClient = require("greenatomy-sdk");
const { GreenatomySdkError } = GreenatomyClient;

try {
  const logs = await client.getLogs();
  console.log(logs);
} catch (error) {
  if (error instanceof GreenatomySdkError) {
    console.error(error.message);
    console.error(error.statusCode);
    console.error(error.code);
  } else {
    throw error;
  }
}

Possible error.code values:

  • UNAUTHORIZED
  • RATE_LIMITED
  • HTTP_ERROR
  • TIMEOUT
  • NETWORK_ERROR

Notes

  • baseUrl is required.
  • Either token or apiKey is required.
  • API keys are project-scoped and generated from the dashboard.
  • Raw API keys are shown only once during creation.
  • Separate API keys can be used per environment for safer production isolation.
  • timeout is optional and defaults to 5000 ms.
  • The client removes trailing slashes from baseUrl.
  • The SDK currently supports logs, telemetry creation, stats, and summary endpoints.
  • The SDK now also includes Express-style middleware for inbound request tracking.
  • token is ideal for authenticated dashboard/user access.
  • apiKey is ideal for project-level telemetry ingestion.

Recommended Onboarding

  1. Register in the hosted dashboard.
  2. Create a project.
  3. Generate an API key for that project.
  4. Save the raw API key when it is shown. It is only displayed once.
  5. Configure the SDK with that API key and your hosted baseUrl.