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

@openfoodfacts/openfoodfacts-nodejs

v2.0.0-alpha.19

Published

Open Food Facts API NodeJS Wrapper

Readme

Open Food Facts - JS SDK

This is the official JS/TS SDK for the Open Food Facts API.

Installation

From NPM

npm install @openfoodfacts/openfoodfacts-nodejs

Using the latest git version

npm install git+https://github.com/openfoodfacts/openfoodfacts-js.git

Usage

[!WARNING] Be sure to read the Open Food Facts API documentation to understand how the API should be used and what data is available BEFORE starting to use the SDK.

Import the SDK in your project and create a client instance:

import { OpenFoodFacts } from "@openfoodfacts/openfoodfacts-nodejs";

// if you're on the browser, you can pass the fetch function as a parameter
const client = new OpenFoodFacts(window.fetch);
// or if you're on Node.js, you can pass the global fetch function
const client = new OpenFoodFacts(globalThis.fetch);
// or if you're using a custom fetch implementation
import fetch from "node-fetch";

const client = new OpenFoodFacts(fetch);

(async () => {
  // then you can use the client to access the Open Food Facts API
  const { data, error } = await client.getProduct("5000112546415");
  if (!data) {
    console.error("Error fetching product:", error);
    return;
  }
  console.log("Product data:", data);
})();

Development

Prerequisites

  • Node.js
  • Yarn v4

API bindings

The project uses openapi-typescript to generate the API bindings automatically from the OpenAPI specification.

To generate the API bindings, run yarn api. The files are to be committed to the repository, so that the SDK can be used without having to download the specs every time.

Building

  • Clone the repository and run yarn install in the directory.
  • Run yarn build to generate the OpenAPI bindings and build the project.
  • Run yarn test to run the tests.

Contribute

We accept contributions of any kind: new features, bug fixes, documentation improvements, etc.

You can also help us by reporting bugs, suggesting improvements or testing new features.

When submitting a PR, please use the angular commit guideline.

Using this SDK and Third party applications

  • If you use this SDK, feel free to open a PR to add your application in the list in REUSERS.md
  • Make sure you comply with the OdBL licence, mentioning the Source of your data, and ensuring to avoid combining non free data you can't release legally as open data. Another requirement is contributing back any product you add using this SDK.