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

ourgroceries

v1.0.0

Published

Unofficial Node.js wrapper for the Our Groceries API

Readme

OurGroceries API - Node.js

Unofficial Node.js wrapper for the Our Groceries API. Requires Node.js >=20.8.1. This is a Node.js port of the original Python library by Leonardo Merza.

Quick Start

npm install ourgroceries

Minimal usage (environment variables recommended for credentials):

import { OurGroceries } from 'ourgroceries';

const og = new OurGroceries(process.env.OG_USERNAME!, process.env.OG_PASSWORD!);

async function main(): Promise<void> {
  await og.login();
  const lists = await og.getMyLists();
  console.log(lists);
}

main().catch(console.error);

Common Operations

Get all lists:

const { shoppingLists } = await og.getMyLists();
shoppingLists.forEach((list) => console.log(`${list.name} (${list.id})`));

Get items in a list:

const { list } = await og.getListItems('list-id');
list.items.forEach((item) => {
  console.log(`[${item.crossedOff ? '✓' : ' '}] ${item.value}`);
});

Add a single item:

await og.addItemToList('list-id', 'Milk', 'Dairy', false, 'Get 2%');

Add multiple items:

await og.addItemsToList('list-id', ['Bread', ['Eggs', 'Dairy'], ['Apples', 'Produce', 'Honeycrisp']]);

Cross off an item:

await og.toggleItemCrossedOff('list-id', 'item-id', true);

Create lists:

await og.createList('Weekly Shopping', 'SHOPPING');
await og.createList('Favorite Recipes', 'RECIPES');

Delete list:

await og.deleteList('list-id');

Remove all crossed off items:

await og.deleteAllCrossedOffFromList('list-id');

Full Example

See examples/basic-usage.ts. To explore without mutating your lists, run the bundled npm script in read-only mode:

npm run example:readonly

The script expects OG_USERNAME and OG_PASSWORD environment variables for authentication and skips write operations when OG_READONLY=true is set (this flag is applied automatically by the npm script). Example scripts automatically load these values from a local .env file when it exists.

TypeScript

import { OurGroceries, InvalidLoginException } from 'ourgroceries';

const og = new OurGroceries(process.env.OG_USERNAME!, process.env.OG_PASSWORD!);

async function run(): Promise<void> {
  await og.login();
  const { shoppingLists } = await og.getMyLists();
  shoppingLists.forEach((list) => console.log(list.name, list.id));
}

run().catch(console.error);

API Methods

login()

Logs into Our Groceries. Returns Promise<void>

getMyLists()

Gets all lists. Returns Promise<Object>

getCategoryItems()

Gets all category items. Returns Promise<Object>

getListItems(listId)

Items for a specific list. Returns Promise<Object>

createList(name, listType='SHOPPING')

Create a new list. Returns Promise<Object>

createCategory(name)

Create a new category. Returns Promise<Object>

toggleItemCrossedOff(listId, itemId, crossOff=false)

Toggle crossed-off state. Returns Promise<Object>

addItemToList(listId, value, category="uncategorized", autoCategory=false, note=null)

Add a single item. Returns Promise<Object>

addItemsToList(listId, items)

Add multiple items. Returns Promise<Object>

removeItemFromList(listId, itemId)

Remove one item. Returns Promise<Object>

getMasterList()

Get master list. Returns Promise<Object>

getCategoryList()

Get category list. Returns Promise<Object>

deleteList(listId)

Delete a list. Returns Promise<Object>

deleteAllCrossedOffFromList(listId)

Bulk delete crossed-off items. Returns Promise<Object>

addItemToMasterList(value, categoryId)

Add item to master list. Returns Promise<Object>

changeItemOnList(listId, itemId, categoryId, value)

Modify an item. Returns Promise<Object>

Exceptions

InvalidLoginException is thrown on failed login.

Tips & Best Practices

  1. Always call await og.login() first
  2. Reuse a single OurGroceries instance
  3. Cache frequently used list IDs
  4. Use autoCategory=true when unsure of category
  5. Wrap API calls in try/catch
  6. Never hardcode credentials

Troubleshooting

Missing credentials:

  • Ensure OG_USERNAME and OG_PASSWORD are set
  • Check with:
    echo $OG_USERNAME
    echo $OG_PASSWORD

Items not appearing:

  • Confirm the correct listId
  • Ensure await og.login() succeeded

Categorization issues:

  • Try autoCategory=true

Transient failures:

  • Add simple retry logic with backoff

Testing (Vitest)

This project uses Vitest for testing.

Run the test suite:

npm test

Watch mode:

npm run test:watch

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT

Credits

Original Python version: https://github.com/ljmerza/py-our-groceries