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

ecoinvent-interface

v1.1.0

Published

JavaScript interface for accessing ecoinvent data

Readme

ecoinvent-interface

npm version License: MIT

A JavaScript/TypeScript library for accessing ecoinvent Life Cycle Assessment (LCA) data. Works in both Node.js and browser environments.

Note: This is an unofficial library. It is not affiliated with or endorsed by ecoinvent.

Quick Start

Installation

npm install @onwp/ecoinvent-interface

Or with yarn:

yarn add @onwp/ecoinvent-interface

Your First Request

import { Settings, EcoinventRelease } from '@onwp/ecoinvent-interface';

// 1. Set up credentials
const settings = new Settings({
  username: 'your-ecoinvent-username',
  password: 'your-ecoinvent-password'
});

// 2. Create interface
const ei = new EcoinventRelease(settings);

// 3. Login and fetch data
await ei.login();
const versions = await ei.listVersions();

console.log('Available versions:', versions);
// Output: ['3.10', '3.9.1', '3.9', '3.8', ...]

That's it! You're now connected to ecoinvent.

Prerequisites

You must have:

  1. A valid ecoinvent account from ecoinvent.org
  2. Accepted the license agreement on their website
  3. Your username and password

Common Use Cases

1. List Available Versions

import { Settings, EcoinventRelease } from '@onwp/ecoinvent-interface';

const ei = new EcoinventRelease(new Settings({
  username: 'your-username',
  password: 'your-password'
}));

await ei.login();
const versions = await ei.listVersions();
console.log(versions);

2. Download a Database Release

import { EcoinventRelease, ReleaseType } from '@onwp/ecoinvent-interface';

const ei = new EcoinventRelease(settings);
await ei.login();

// Download the matrix format for version 3.9.1, cutoff system model
const path = await ei.getRelease('3.9.1', 'cutoff', ReleaseType.MATRIX);
console.log('Downloaded to:', path);

3. Get Process Information

import { EcoinventProcess, ProcessFileType } from '@onwp/ecoinvent-interface';

const process = new EcoinventProcess(settings);
await process.login();

// Select version and process
await process.setRelease('3.9.1', 'cutoff');
process.selectProcess('12345'); // dataset ID

// Get information
const info = await process.getBasicInfo();
const docs = await process.getDocumentation();

// Download process file
const pdfPath = await process.getFile(ProcessFileType.PDF, '/path/to/save');

4. Download Reports

const ei = new EcoinventRelease(settings);
await ei.login();

// List all reports
const reports = await ei.listReportFiles();
console.log(Object.keys(reports));

// Download a specific report
const reportPath = await ei.getReport('implementation_report.pdf');

Authentication Options

Option 1: Direct in Code (Quick Start)

const settings = new Settings({
  username: 'your-username',
  password: 'your-password'
});

Option 2: Environment Variables (Recommended for Production)

export EI_USERNAME=your-username
export EI_PASSWORD=your-password
const settings = new Settings(); // Reads from environment automatically

Option 3: Persistent Storage

import { permanentSetting } from '@onwp/ecoinvent-interface';

// Store once
permanentSetting('username', 'your-username');
permanentSetting('password', 'your-password');

// Use anywhere
const settings = new Settings(); // Reads from storage automatically

Available Data Formats

import { ReleaseType } from '@onwp/ecoinvent-interface';

// Choose your format:
ReleaseType.ECOSPOLD        // Unit process XML files
ReleaseType.MATRIX          // Universal matrix export (recommended)
ReleaseType.LCI             // Life cycle inventory XML
ReleaseType.LCIA            // Impact assessment XML
ReleaseType.CUMULATIVE_LCI  // Cumulative LCI (Excel)
ReleaseType.CUMULATIVE_LCIA // Cumulative LCIA (Excel)

System Models

// Available system models (use abbreviation):
'cutoff'        // Allocation cut-off by classification
'consequential' // Substitution, consequential, long-term
'apos'          // Allocation at the Point of Substitution
'EN15804'       // Allocation, cut-off, EN15804

// Example:
await ei.getRelease('3.9.1', 'cutoff', ReleaseType.MATRIX);

Browser Usage

Works out of the box in browsers:

<!DOCTYPE html>
<html>
<head>
  <script type="module">
    import { Settings, EcoinventRelease } from '@onwp/ecoinvent-interface';

    const settings = new Settings({
      username: 'your-username',
      password: 'your-password'
    });

    const ei = new EcoinventRelease(settings);
    await ei.login();
    const versions = await ei.listVersions();

    console.log('Versions:', versions);
  </script>
</head>
<body>
  <h1>Ecoinvent Browser Example</h1>
</body>
</html>

React Example

import React, { useState, useEffect } from 'react';
import { Settings, EcoinventRelease } from '@onwp/ecoinvent-interface';

function EcoinventData() {
  const [versions, setVersions] = useState([]);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    async function loadVersions() {
      const settings = new Settings({
        username: process.env.REACT_APP_EI_USERNAME,
        password: process.env.REACT_APP_EI_PASSWORD
      });

      const ei = new EcoinventRelease(settings);
      await ei.login();
      const data = await ei.listVersions();

      setVersions(data);
      setLoading(false);
    }

    loadVersions();
  }, []);

  if (loading) return <div>Loading...</div>;

  return (
    <div>
      <h1>Available Versions</h1>
      <ul>
        {versions.map(v => <li key={v}>{v}</li>)}
      </ul>
    </div>
  );
}

Advanced Features

Process Mapping with Fuzzy Matching

import { ProcessMapping } from '@onwp/ecoinvent-interface';

const mapping = new ProcessMapping(settings);

// Create remote mapping (from API)
const remoteProcesses = await mapping.createRemoteMapping(
  '3.9.1',
  'cutoff',
  100  // max ID to fetch
);

// Create local mapping (from downloaded files)
const localProcesses = mapping.createLocalMapping(
  'ecoinvent 3.9.1_cutoff_ecoSpold02'
);

// Find matches using fuzzy matching
const matches = mapping.matchProcesses(localProcesses, remoteProcesses);
console.log(`Found ${matches.length} matches`);

// Find specific match
const match = mapping.findClosestMatch(
  localProcesses[0],
  remoteProcesses,
  10 // Levenshtein distance threshold
);

Get Excel LCIA Files

import { getExcelLciaFileForVersion } from '@onwp/ecoinvent-interface';

const excelPath = await getExcelLciaFileForVersion(ei, '3.9.1');
console.log('LCIA Excel file:', excelPath);

Logging and Debugging

import { setLogLevel, LogLevel } from '@onwp/ecoinvent-interface';

// Enable debug logging
setLogLevel(LogLevel.DEBUG);

// Now all operations will log detailed information
const ei = new EcoinventRelease(settings);
await ei.login(); // Will show detailed login process

Cache and Storage

Files are automatically cached to avoid re-downloading:

Cache Locations:

  • macOS: ~/Library/Caches/ecoinvent-interface
  • Windows: %LOCALAPPDATA%\ecoinvent-interface\Cache
  • Linux: ~/.cache/ecoinvent-interface
  • Browser: IndexedDB or localStorage

Custom Cache Directory:

const settings = new Settings({
  username: 'user',
  password: 'pass',
  outputPath: '/custom/cache/path'
});

API Reference

Classes

  • Settings - Authentication and configuration
  • EcoinventRelease - Access database releases
  • EcoinventProcess - Access individual processes
  • ProcessMapping - Map between local and remote processes
  • CachedStorage - Manage cached files

Enums

  • ReleaseType - Database format types
  • ProcessFileType - Process file types (UPR, LCI, LCIA, PDF)
  • LogLevel - Logging levels (ERROR, WARN, INFO, DEBUG)

Methods

EcoinventRelease

  • login() - Authenticate with ecoinvent
  • listVersions() - Get available versions
  • listSystemModels(version) - Get system models
  • getRelease(version, model, type) - Download database
  • listReportFiles() - List available reports
  • getReport(filename) - Download report
  • listExtraFiles(version) - List extra files
  • getExtra(version, filename) - Download extra file

EcoinventProcess

  • setRelease(version, model) - Set version/model
  • selectProcess(datasetId) - Select process by ID
  • getBasicInfo() - Get process metadata
  • getDocumentation() - Get XML documentation
  • getFile(fileType, directory) - Download process file

ProcessMapping

  • createRemoteMapping(version, model, maxId) - Fetch from API
  • createLocalMapping(cacheKey) - Parse local files
  • findClosestMatch(local, remotes, threshold) - Find match
  • matchProcesses(locals, remotes) - Match all processes
  • addMapping(data, version, model) - Save mapping

TypeScript Support

Full TypeScript definitions included:

import {
  Settings,
  EcoinventRelease,
  ReleaseType,
  EcoinventProcess,
  ProcessFileType,
  ISettings
} from '@onwp/ecoinvent-interface';

const settings: ISettings = {
  username: 'user',
  password: 'pass'
};

const ei: EcoinventRelease = new EcoinventRelease(new Settings(settings));

Troubleshooting

Authentication Errors

Error: "Missing username" or "Missing password"

// Solution: Make sure credentials are set
const settings = new Settings({
  username: 'your-username',  // ← Don't forget these!
  password: 'your-password'
});

File Not Found

Error: "Version X.X.X not found"

// Solution: Check available versions first
const versions = await ei.listVersions();
console.log('Available:', versions);

Network Timeouts

// The library has built-in 20-second timeouts
// If you need longer, you may need to adjust your network

Examples

See the examples/ directory for complete working examples:

  • examples/basic-usage.js - Simple version listing
  • More examples coming soon

Migration from Python

If you're migrating from the Python package:

| Python | JavaScript/TypeScript | |--------|----------------------| | list_versions() | listVersions() | | get_release() | getRelease() | | system_model | systemModel | | output_path | outputPath |

All functionality is available with JavaScript naming conventions (camelCase).

Requirements

  • Node.js: 14.0 or higher
  • Browsers: Modern browsers with ES6 support
  • ecoinvent Account: Required for API access

Development

# Install dependencies
npm install

# Run tests
npm test

# Build
npm run build

# Watch mode
npm run dev

License

MIT License - see LICENSE file

Support

Changelog

Version 1.1.0 (Latest)

  • ✨ Added getExcelLciaFileForVersion() utility function
  • ✨ Added ProcessMapping.addMapping() for storing mappings
  • ✨ Enhanced fuzzy matching with findClosestMatch() and matchProcesses()
  • 📚 Comprehensive test suite
  • 📖 Improved documentation
  • 🌐 Full browser compatibility

Version 1.0.0

  • 🎉 Initial release
  • ✅ Complete feature parity with Python package
  • ✅ TypeScript support
  • ✅ Browser and Node.js support

Acknowledgments

This library is a TypeScript port of the Python ecoinvent-interface package by Chris Mutel.

Disclaimer

This is an unofficial and unsupported library. It is not affiliated with or endorsed by ecoinvent. The library interacts with ecoinvent's API which may change without notice.


Made with ❤️ for the LCA community