Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Print API

node v8.17.0
version: 2.0.0
endpointsharetweet
INSTALL PRINT-API MODULE Require the print-api package and set a apiKey.
const apiKey = 'EFLDjI7hR6833ZSrLe8psZyFh5j6QKE2nWAkWOC3'; const print = require("print-api")(apiKey, { test: true });
GET A PRINT QUOTE AND DELIVERY PROMISE We need a request data containing a valid product, destination and currency information. Print-api comes with an example method to get a valid data object you can use.
let example = print.example(); console.log(example);
Once we have the data ready, we request a quote.
let response = await print.quote(example); console.log(response.body);
PLACING AN ORDER The quote request, returns a production object, containing country of production, and possible shipment methods to the destination, with different min and max delivery days. Select one of the shipment methods promiseUid to place an order.
let shipments = response.body.production.shipments; let order = await print.order(shipments[0].promiseUid); console.log(order.body);
STATUS OF ORDER After you have successfully placed an order, you can ask for the order status. Just use the orderRefenceId you provided in the quote request.
let status = await print.status(response.body.orderReferenceId); console.log(status.body);
CANCEL AN ORDER To cancel the order again use the orderReferenceId and the cancel method.
let cancel = await print.cancel(response.body.orderReferenceId); console.log(cancel.body);
Loading…

no comments

    sign in to comment