Registry / ecommerce / magento-api-rest

magento-api-rest

JSON →
library2.0.4jsnpmunverified

A Node.js client wrapper for the Magento REST API, version 2.0.4. Supports OAuth 1.0a authentication, CRUD operations (GET, POST, PUT, DELETE), configurable endpoint type (default V1, async/V1, async/bulk/V1), SHA version (1 or 256), timeout, and custom axios config. Ships TypeScript types. Compatible with Node >=8.0.0. Unlike other wrappers, it offers direct async/bulk endpoint support and full OAuth flow.

npm install magento-api-rest
INSTALL
IMPORT
SIG · MAGENTO-API-REST
M
magento-api-rest
ecommercejavascriptv2.0.4
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.

Magento
import Magento from 'magento-api-rest'
const Magento = require('magento-api-rest')
ESM default import works in TypeScript and modern Node. CommonJS users must use require('magento-api-rest').default.
Magento (default export)
const Magento = require('magento-api-rest').default
const Magento = require('magento-api-rest')
In CommonJS, the module exports an object with a 'default' property containing the class.
MagentoConfig
import type { MagentoConfig } from 'magento-api-rest'
import { MagentoConfig } from 'magento-api-rest'
MagentoConfig is a TypeScript type available via import type. Not exported at runtime.

Shows how to instantiate the Magento client with OAuth credentials and make a GET request to fetch orders.

import Magento from 'magento-api-rest'; const client = new Magento({ url: process.env.MAGENTO_URL ?? 'https://magento.example.com', consumerKey: process.env.MAGENTO_CONSUMER_KEY ?? '', consumerSecret: process.env.MAGENTO_CONSUMER_SECRET ?? '', accessToken: process.env.MAGENTO_ACCESS_TOKEN ?? '', tokenSecret: process.env.MAGENTO_TOKEN_SECRET ?? '', }); async function getOrders() { try { const orders = await client.get('orders', { searchCriteria: { pageSize: 10 } }); console.log(orders); } catch (err) { console.error('Error fetching orders:', err); } } getOrders();
Debug
Known issues
gotchaIn CommonJS, require('magento-api-rest') returns an object with a 'default' property, not the class directly.
fix
Use require('magento-api-rest').default.
affects: >=2.0.0
breakingDropped support for Node < 8.0.0.
fix
Upgrade Node.js to version >= 8.0.0.
affects: >=2.0.0
gotchaThe 'type' option defaults to 'V1'; using async endpoints requires setting 'type' to 'async/V1' or 'async/bulk/V1'.
fix
Set type: 'async/V1' in the constructor options.
affects: >=1.0.0
gotchaOAuth 1.0a credentials are required; this package does not support token-based authentication (e.g., admin tokens).
fix
Generate OAuth 1.0a integration credentials from Magento admin.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Magento is not a constructor
In CommonJS, the import returns an object with a 'default' property, not the class directly.
fix
Use const Magento = require('magento-api-rest').default;
Cannot find module 'magento-api-rest'
Package not installed or wrong import path.
fix
Run npm install magento-api-rest and ensure the import is correct.
Error: Request failed with status code 401
Invalid or missing OAuth credentials, or incorrect endpoint type.
fix
Verify OAuth credentials and ensure the 'type' option matches the intended endpoint.
Upgrade
Version history
2.0.4latest on npm
Audit
Dependencies
axiosrequiredHTTP client for making REST requests
oauth-1.0arequiredOAuth 1.0a signature generation
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
magento-api-rest — npm install magento-api-rest · libregistry