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

node-grocy

v0.1.0

Published

A JavaScript wrapper for the Grocy REST API

Readme

node-grocy

A JavaScript wrapper for the Grocy REST API.

About

node-grocy is a comprehensive client library for interacting with Grocy, an open-source self-hosted ERP system for your groceries and household management. This library provides a clean, Promise-based interface to all Grocy API endpoints.

Features

  • Full coverage of the Grocy API
  • Promise-based async/await interface
  • Error handling for various response types
  • Comprehensive test suite
  • No external dependencies

Installation

npm install node-grocy

Usage

import Grocy from 'node-grocy';

// Initialize client
const grocy = new Grocy('https://your-grocy-instance.com', 'your-api-key');

// Get all products in stock
async function getStock() {
  try {
    const stock = await grocy.getStock();
    console.log('Products in stock:', stock);
  } catch (error) {
    console.error('Error fetching stock:', error.message);
  }
}

// Add a product to stock
async function addProduct(productId) {
  try {
    const data = {
      amount: 1,
      best_before_date: '2023-12-31',
      transaction_type: 'purchase',
      price: 2.99
    };
    const result = await grocy.addProductToStock(productId, data);
    console.log('Product added:', result);
  } catch (error) {
    console.error('Error adding product:', error.message);
  }
}

// Get volatile stock (due soon, overdue, expired, missing)
async function getVolatileStock() {
  try {
    const volatileStock = await grocy.getVolatileStock(7); // Products due within 7 days
    console.log('Products due soon:', volatileStock.due_products);
    console.log('Products overdue:', volatileStock.overdue_products);
    console.log('Products expired:', volatileStock.expired_products);
    console.log('Products missing:', volatileStock.missing_products);
  } catch (error) {
    console.error('Error fetching volatile stock:', error.message);
  }
}

API Reference

Constructor

const grocy = new Grocy(baseUrl, apiKey);
  • baseUrl: The base URL of your Grocy instance (with or without /api suffix)
  • apiKey: Your Grocy API key

Methods

The library includes methods for all Grocy API endpoints, organized into these categories:

System

  • getSystemInfo(): Get information about the Grocy instance
  • getDbChangedTime(): Get the time when the database was last changed
  • getConfig(): Get all config settings
  • getTime(offset): Get the current server time

Stock Management

  • getStock(): Get all products in stock
  • getStockEntry(entryId): Get a specific stock entry
  • editStockEntry(entryId, data): Edit a stock entry
  • getVolatileStock(dueSoonDays): Get products due soon, overdue, expired, or missing
  • getProductDetails(productId): Get details of a product
  • getProductByBarcode(barcode): Get product by barcode
  • addProductToStock(productId, data): Add product to stock
  • addProductToStockByBarcode(barcode, data): Add product to stock by barcode
  • consumeProduct(productId, data): Consume product from stock
  • consumeProductByBarcode(barcode, data): Consume product by barcode
  • transferProduct(productId, data): Transfer product between locations
  • inventoryProduct(productId, data): Set new amount for product
  • openProduct(productId, data): Mark product as opened

...and many more for shopping lists, chores, recipes, tasks, etc.

For detailed documentation on all methods and their parameters, please see the full API documentation.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.