@iqz/oriole
v0.14.0
Published
A NodeJS REST client for Magento 2 with full Typescript support.
Downloads
5
Readme
Oriole
A NodeJS REST client for Magento 2 with full Typescript support.
This package is largely inspired by Marko Nouvak's magento2-rest-client and Divante Ltd.'s magento2-rest-client packages. What they lacked was full Typescript support, which we've filled in, with some additional tweaks of our own.
This module also uses a full Typescript rewrite of Ddo's oauth-1.0a module among others.
This is a Work-in-Progress. Only a subset of Magento's REST API is implemented. You can help by submitting a PR.
Why "Oriole"?
We were building something else called as Bluebird when this one happened as a by-product. We wanted to have something similarly named. Magento's branding scheme is orange-ish (?) so we did a Google search for "orange coloured birds" and an "oriole" popped up in the results. Hence the name. :P
Installation
npm install @iqz/oriole --save
Usage
You will need to either create an "integration" with Magento 2 or obtain a user token.
To create an integration, you'll have to go to System > Extensions > Integrations
and Add New Integration
in the Magento 2 admin panel. Give a name and select the scope of the API and save it to obtain the OAuth keys. Then you can do:
import { Oriole } from '@iqz/oriole';
const o = new Oriole({
oauth: {
consumerKey: '<your magento consumer key>',
consumerSecret: '<your magento consumer secret>',
accessToken: '<your magento access token>',
accessTokenSecret: '<your magento access secret>'
},
url: 'http://localhost:8080/rest' // Put your URL here. It should end with '/rest'
});
console.log(await o.products.list('carrot')); // Gets you a list of all products searchable by 'carrot'
If you are using a user token, replace the oauth
property above with bearer
property.
Changelog
The changelog is available here.