Registry / ecommerce / magento2-rest-client

magento2-rest-client

JSON →
library0.0.2jsnpmunverified

A Node.js library for communicating with Magento 2 sites via their REST API using OAuth 1.0a authentication. Version 0.0.2 is the latest and only release. This library is early-stage and incomplete, covering only a subset of Magento 2 API endpoints. It uses promises (unlike callback-based alternatives) and supports categories, products, and customer operations. The project appears to be abandoned with no recent commits.

npm install magento2-rest-client
INSTALL
IMPORT
SIG · MAGENTO2-REST-CLIE
M
magento2-rest-client
ecommercejavascriptv0.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Magento2Client
const { Magento2Client } = require('magento2-rest-client');
const Magento2Client = require('magento2-rest-client');
Magento2Client is a named export, not the default. CommonJS require must destructure it.
Magento2Client (ESM)
import { Magento2Client } from 'magento2-rest-client';
import Magento2Client from 'magento2-rest-client';
ESM syntax also requires named import; no default export exists.
Product
const { Product } = require('magento2-rest-client').Magento2Client;
const Product = require('magento2-rest-client').Product;
Product is under the Magento2Client namespace; not directly exported.

Initializes the client with OAuth credentials and fetches the category list.

const { Magento2Client } = require('magento2-rest-client'); const options = { url: 'http://www.test.com/index.php/rest', consumerKey: process.env.CONSUMER_KEY ?? '', consumerSecret: process.env.CONSUMER_SECRET ?? '', accessToken: process.env.ACCESS_TOKEN ?? '', accessTokenSecret: process.env.ACCESS_TOKEN_SECRET ?? '' }; const client = Magento2Client(options); client.categories.list() .then(categories => { console.log('Categories:', categories); }) .catch(err => console.error(err));
Debug
Known issues
breakingOnly a subset of Magento2 API endpoints are implemented; many operations will fail.
fix
Extend the library or use the official Magento 2 REST API with a generic HTTP client.
affects: =0.0.2
deprecatedThe library relies on callbacks/promises but is not actively maintained; consider alternatives.
fix
Use 'magento2-api' or 'magento2-rest-client-kirchberger' as alternative maintained libraries.
affects: =0.0.2
gotchaMagento2Client is a named export, not default. Common mistake: const Magento2Client = require('magento2-rest-client') returns an object with Magento2Client property.
fix
Use destructuring: const { Magento2Client } = require('magento2-rest-client');
affects: =0.0.2
gotchaThe library does not support Magento 2's token-based authentication (Bearer tokens); only OAuth 1.0a.
fix
Ensure your Magento 2 integration is configured for OAuth 1.0a, or use another library that supports Bearer tokens.
affects: =0.0.2
Errors
Common errors & fixes
TypeError: Magento2Client is not a constructor
Importing the default export instead of named export.
fix
Replace 'const Magento2Client = require('magento2-rest-client');' with 'const { Magento2Client } = require('magento2-rest-client');'
Error: Cannot find module 'magento2-rest-client'
Package not installed or named incorrectly.
fix
Run 'npm install magento2-rest-client' from the project root.
TypeError: client.categories.list is not a function
The categories endpoint is not fully implemented or the API version mismatch.
fix
Check that the Magento 2 REST API endpoint URL is correct and the library supports the required version.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
oauth-1.0arequiredUsed for OAuth 1.0a signature generation
Agent activity
22 hits · last 30 days
node
20
Resources
magento2-rest-client — npm install magento2-rest-client · libregistry