A promise based client for the Neto Ecommerce API.
You will no longer be able to import the module using it's default namespace - imports of this module will need to be changed to the following syntax:
// ES6 import const { NetoAPI } = require('neto-api'); const mySite = new NetoAPI({...}); // TypeScript import import { NetoAPI } from 'neto-api'; const mySite = new NetoAPI({...}); // Older syntax var neto = require('neto-api'); var mySite = new neto.NetoAPI({...});Before you start making calls, you will need to initialise the API like so:
const { NetoAPI } = require('neto-api'); const mySite = new NetoAPI({ url: 'https://myawesomesite.neto.com.au', key: 'api-key', user: 'user' // optional });Once the library is initialised, you can use it like so:
mySite .type // See below for a list of supported types .method() // See below for a list of methods for each type (generally add, get or update) .exec() // Returns a promise that resolves with the API response in JSON format .then(response) // Response object is returned via callback .catch(err) // Always handle your errors ;) mySite.item .add({ SKU: 'smp_3' }) .exec() .then((response) => { console.log(response); }) .catch((err) => console.log(err));mySite.order .get({ OrderStatus: ['New', 'Pick'] }) .output(['OrderID']) .exec() .then((response) => { for (let order of response.Order) { console.log(order); } }) .catch((err) => console.log(err));mySite.customer .update({ Username: 'someguy', EmailAddress: 'bob@email.com'}) .exec() .then((response) => { console.log(response); }) .catch((err) => console.log(err));.add() and .update() methods can be chained together with themselves to improve readability - the request itself will only be sent when .exec() is called. Check it out below:
mySite.item .add({ SKU: 'smp_1' }) .add({ SKU: 'smp_2' }) .add({ SKU: 'smp_3' }) .exec() .then((response) => { console.log(response); }) .catch((err) => console.log(err));This allows you to some other cool stuff, such as building a bulk request to execute at some time in the future:
// Expose a copy of the request type var addItems = api.item; // Do some stuff... addItems = addItems.add({ SKU: 'smp_1' }); // Do some other stuff... addItems = addItems.add({ SKU: 'smp_2' }); // Keep building the request... addItems = addItems.add({ SKU: 'smp_3' }); // Finally execute the request at a later time addItems.exec() .then((response) => { console.log(response); }) .catch((err) => console.log(err));Chaining .get() methods will be supported soon, I promise.
Because this library is built on promises, it supports the use of async and await operators. Here's an example:
async function addItem() { try { var response = mySite.item.add({ SKU: 'smp_1' }).exec(); // Do some stuff... console.log(await response); } catch (err) { console.log(err); } } addItem();It's that easy!
| Method | Neto API Action |
|---|---|
.get( CartFilter ) | GetCart |
| Method | Neto API Action |
|---|---|
.add( Category | Category[] ) | AddCategory |
.get( CategoryFilter ) | GetCategory |
.update( Category | Category[] ) | UpdateCategory |
| Method | Neto API Action |
|---|---|
.add( Content | Content[] ) | AddContent |
.get( ContentFilter ) | GetContent |
.update( Content | Content[] ) | UpdateContent |
| Method | Neto API Action |
|---|---|
.getSettings() | GetCurrencySettings |
.updateSettings( CurrencySettings ) | UpdateCurrencySettings |
| Method | Neto API Action |
|---|---|
.add( Customer | Customer[] ) | AddCustomer |
.get( CustomerFilter ) | GetCustomer |
.update( Customer | Customer[] ) | UpdateCustomer |
.addLog( CustomerLog | CustomerLog[] ) | AddCustomerLog |
.updateLog( CustomerLog | CustomerLog[] ) | UpdateCustomerLog |
| Method | Neto API Action |
|---|---|
.add( Item | Item[] ) | AddItem |
.get( ItemFilter ) | GetItem |
.update( Item | Item[] ) | UpdateItem |
| Method | Neto API Action |
|---|---|
.add( Order | Order[] ) | AddOrder |
.get( OrderFilter ) | GetOrder |
.update( Order | Order[] ) | UpdateOrder |
| Method | Neto API Action |
|---|---|
.add( Payment | Payment[] ) | AddPayment |
.get( PaymentFilter ) | GetPayment |
.getMethods() | GetPaymentMethods |
| Method | Neto API Action |
|---|---|
.add( Rma | Rma[] ) | AddRma |
.get( RmaFilter ) | GetRma |
| Method | Neto API Action |
|---|---|
.getMethods() | GetShippingMethods |
.getQuote( ShippingQuote ) | GetShippingQuote |
| Method | Neto API Action |
|---|---|
.add( Supplier | Supplier[] ) | AddSupplier |
.get( SupplierFilter ) | GetSupplier |
.update( Supplier | Supplier[] ) | UpdateSupplier |
| Method | Neto API Action |
|---|---|
.add( Voucher | Voucher[] ) | AddVoucher |
.get( VoucherFilter ) | GetVoucher |
.update( Voucher | Voucher[] ) | UpdateVoucher |
| Method | Neto API Action |
|---|---|
.add( Warehouse | Warehouse[] ) | AddWarehouse |
.get( WarehouseFilter ) | GetWarehouse |
.update( Warehouse | Warehouse[] ) | UpdateWarehouse |
- Accounting
-
UpdateAccountingSystemRelatedAccount -
DeleteAccountingSystemRelatedAccount -
AddAccountingSystemRelatedAccount -
GetAccountingSystemRelatedAccounts
-
Neto API documentation available here.
Note: This is currently a personal project of mine and is not offically endorsed or supported by Neto.