@stylusapparel/shipstation-api-node v0.0.4
stylusapparel/shipstation-api-node
A NodeJS wrapper for connecting to ShipStation system using the auth credentials provided from ShipStation. You can also view the full documentation of Stylus APIs here
Install
$ npm install @stylusapparel/shipstation-api-node
OR
$ yarn add @stylusapparel/shipstation-api-node
Usage
After having installed it, simply require it and create an instance of wrapper using your own shipstation apiKey
and apiSecret
, and start calling methods!
const shipStationWrapper = require("@stylusapparel/node-shipstation");
const shipStationWrapperClient = shipStationWrapper.createClient(
"YOUR_SHIPSTATION_API_KEY",
"YOUR_SHIPSTATION_API_SECRET",
{
// additional http options
timeout: 3000, // optional, request timeout in milliseconds
}
);
Orders
Get Order
This method can be used to retrieve a single order by orderId
.
shipStationWrapperClient.orders
.get(orderId)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the get order request/response payload here
Get All Orders
Obtains a list of orders that match the specified criteria. All of the available filters are optional.
shipStationWrapperClient.orders
.getAll({
// filter object
customerName: "stylus",
itemKeyword: "leggings",
sortBy: "OrderDate",
pageSize: 100,
})
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the get all orders request/response payload here
Create Order
Create a new order or update an existing order. If the orderKey
is specified, ShipStation will attempt to locate the order with the specified orderKey
. If found, the existing order with that key will be updated. If the orderKey
is not found, a new order will be created with that orderKey
.
shipStationWrapperClient.orders.create({
"orderNumber": "TEST-ORDER-API-DOCS",
"orderKey": "0f6bec18-3e89-4881-83aa-f392d84f4c74",
"orderDate": "2015-06-29T08:46:27.0000000",
"paymentDate": "2015-06-29T08:46:27.0000000",
"shipByDate": "2015-07-05T00:00:00.0000000",
...
...
...
})
.then((response) => {
console.log("success",response); // true
})
.catch((error) => {
console.log("error",error.status,error);
});
You can see create order request/response payload here
Note:- This method does not support partial updates, the entire resource must be provided. For partial update, use .update()
function.
Create Orders
Create or Update multiple orders in one request. If the orderKey
is specified, ShipStation will attempt to locate the order with the specified orderKey
. If found, the existing order with that key will be updated. If the orderKey
is not found, a new order will be created with that orderKey
.
shipStationWrapperClient.orders.bulkCreate([{
"orderNumber": "TEST-ORDER-API-DOCS",
"orderKey": "0f6bec18-3e89-4881-83aa-f392d84f4c74",
"orderDate": "2015-06-29T08:46:27.0000000",
"paymentDate": "2015-06-29T08:46:27.0000000",
"shipByDate": "2015-07-05T00:00:00.0000000",
...
...
...
}])
.then((response) => {
console.log("success",response); // true
})
.catch((error) => {
console.log("error",error.status,error);
});
You can see the bulk order create request/response payload here
Note:- This method does not support partial updates, the entire resource must be provided.
Update Order
This method can be used to partially update an order by providing orderId
and update payload.
shipStationWrapperClient.orders.update(orderId, {
"paymentDate": "2015-07-02T06:46:29.0000000",
"shipByDate": "2015-08-04T02:11:10.0000000",
...
...
...
})
.then((response) => {
console.log("success",response);
})
.catch((error) => {
console.log("error",error.status,error);
});
You can see the order update request/response payload here
Delete Order
Removes an order from ShipStation's UI. Note this is a "soft" delete action so the order will still exist in the shipstation database as inactive.
shipStationWrapperClient.orders
.delete(orderId)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the delete order request/response payload here
Cancel Order
Cancel an order by marking orderStatus as cancelled
.
shipStationWrapperClient.orders
.cancel(orderId)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
Response payload for cancel order is same as order update function response
Create Order Label
Creates a shipping label for a given order. The labelData field returned in the response is a base64 encoded PDF value. Simply decode and save the output as a PDF file to retrieve a printable label.
shipStationWrapperClient.orders
.label(orderId, {
carrierCode: "fedex",
serviceCode: "fedex_2day",
packageCode: "package",
confirmation: null,
shipDate: "2014-04-03",
...
...
...
})
.then((response) => {
console.log("success",response);
})
.catch((error) => {
console.log("error",error.status,error);
});
You can see the order label request/response payload here
Mark an Order as Shipped
Marks an order as shipped without creating a label in ShipStation.
shipStationWrapperClient.orders
.markShipped(orderId, {
orderId: 93348442,
carrierCode: "usps",
shipDate: "2014-04-01",
trackingNumber: "913492493294329421",
notifyCustomer: true,
notifySalesChannel: true,
})
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the delete order request/response payload here
Hold Order Until
This method will change the status of the given order to On Hold until the date specified, when the status will automatically change to Awaiting Shipment.
shipStationWrapperClient.orders
.hold(orderId, holdUntilDate)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the delete order request/response payload here
Shipments
Create Shipment Label
Creates a shipping label. The labelData
field returned in the response is a base64 encoded PDF value. Simply decode and save the output as a PDF file to retrieve a printable label.
shipStationWrapperClient.shipments
.createLabel({
carrierCode: "fedex",
serviceCode: "fedex_ground",
packageCode: "package",
...
...
...
})
.then((response) => {
console.log("success",response);
})
.catch((error) => {
console.log("error",error.status,error);
});
You can see the shipment label request/response payload here
Get Rates
Retrieves shipping rates for the specified shipping details.
shipStationWrapperClient.shipments
.getRates({
carrierCode: "fedex",
serviceCode: null,
packageCode: null,
...
...
...
})
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the shipment rates request/response payload here
Get All Shipments
Obtains a list of shipments that match the specified criteria.
shipStationWrapperClient.shipments
.getAll({
recipientName: "stylus",
recipientCountryCode: "US",
pageSize: 15,
...
...
...
})
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the shipment list request/response payload here
Void Shipment Label
Voids the specified label by shipmentId.
shipStationWrapperClient.shipments
.voidLabel(shipmentId)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the shipment label void request/response payload here
Carriers
Get Carrier By Code
Retrieves the shipping carrier account details for the specified carrierCode. Use this method to determine a carrier's account balance.
shipStationWrapperClient.carriers
.get(carrierCode)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carrier info request/response payload here
Get All Carriers
List all shipping providers connected to this account.
shipStationWrapperClient.carriers
.getAll()
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carriers list request/response payload here
Get All Services
Retrieves the list of available shipping services provided by the specified carrier
shipStationWrapperClient.carriers
.getAllServices(carrierCode)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carriers list request/response payload here
Get All Packages
Retrieves a list of packages for the specified carrier.
shipStationWrapperClient.carriers
.getAllPackages(carrierCode)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carriers list request/response payload here
WareHouses
Create Warehouse
Adds a Ship From Location (formerly known as warehouse) to your account.
shipStationWrapperClient.warehouses
.create({
warehouseName: "New Ship From Location",
originAddress: {
name: "NM Warehouse",
company: "White Sands Co.",
street1: "4704 Arabela Dr.",
street2: null,
street3: null,
city: "Las Cruces",
state: "NM",
postalCode: "80012",
country: "US",
phone: "512-111-2222",
residential: true,
},
returnAddress: null,
isDefault: false,
})
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carrier info request/response payload here
Get Warehouse
Returns a list of active Ship From Locations (formerly known as warehouses) on the ShipStation account.
shipStationWrapperClient.warehouses
.get(warehouseId)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carrier info request/response payload here
Get All Warehouse
Retrieves a list of your Ship From Locations (formerly known as warehouses).
shipStationWrapperClient.warehouses
.getAll()
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carrier info request/response payload here
Update Warehouse
Updates an existing Ship From Location (formerly known as warehouse). This call does not currently support partial updates. The entire resource must be provided in the body of the request. If a "returnAddress" object is not specified, your "originAddress" will be used as your "returnAddress".
shipStationWrapperClient.warehouses
.update({
warehouseId: 12345,
warehouseName: "API Ship From Location",
originAddress: {
name: "API Warehouse",
company: "ShipStation",
street1: "2815 Exposition Blvd",
street2: null,
street3: null,
...
...
...
},
returnAddress: {
name: "API Ship From Location",
company: "ShipStation",
...
...
...
},
createDate: "2015-07-02T08:38:31.4870000",
isDefault: true,
})
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carrier info request/response payload here
Delete Warehouse
Removes a warehouse from ShipStation's UI.
shipStationWrapperClient.warehouses
.delete(warehouseId)
.then((response) => {
console.log("success", response);
})
.catch((error) => {
console.log("error", error.status, error);
});
You can see the carrier info request/response payload here