PostnlShippingClient - JavaScript client for postnl_shipping_client A NodeJS API client for PostNL shipping services. Features include Generating barcdes, Generating labels in Base64
- API version: 1.0.0
- Package version: 1.0.0
For Node.js
To publish the library as a npm, please follow the procedure in "Publishing npm packages".
Then install it via:
npm install postnl_shipping_client --save
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing
into the directory containing package.json
(and this README). Let's call this JAVASCRIPT_CLIENT_DIR
. Then run:
npm install
Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR
:
npm link
Finally, switch to the directory you want to use your postnl_shipping_client from, and run:
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
You should now be able to require('postnl_shipping_client')
in javascript files from the directory you ran the last
command above from.
If the library is hosted at a git repository, e.g. https://github.com/trackq/postnl_shipping_client then install it via:
npm install trackq/postnl_shipping_client --save
The library also works in the browser environment via npm and browserify. After following
the above steps with Node.js and installing browserify with npm install -g browserify
,
perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually
use this library):
browserify main.js > bundle.js
Then include bundle.js in the HTML pages.
Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
Please follow the installation instruction and execute the following JS code:
var PostnlShippingClient = require('postnl_shipping_client');
var api = new PostnlShippingClient.DefaultApi()
var apikey = "apikey_example"; // {String} authenticate using your API key
var customerCode = "DEVC"; // {String} Customer code as known at PostNL Pakketten
var customerNumber = "11223344"; // {String} Customer number as known at PostNL Pakketten
var type = "3S"; // {String} Accepted values are: 2S, 3S, CC, CP, CD, CF
var opts = {
'serie': "000000000-999999999" // {String} Barcode serie in the format '###000000-###000000', for example 100000-20000. The range must consist of a minimal difference of 100.000. Minimum length of the serie is 6 characters; maximum length is 9 characters. It is allowed to add extra leading zeros at the beginning of the serie. See Guidelines for more information.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.v11BarcodeGet(apikey, customerCode, customerNumber, type, opts, callback);
All URIs are relative to https://api-sandbox.postnl.nl/shipment
Class | Method | HTTP request | Description |
---|---|---|---|
PostnlShippingClient.DefaultApi | v11BarcodeGet | GET /v1_1/barcode | Generate standard barcode |
PostnlShippingClient.DefaultApi | v21LabelPost | POST /v2_1/label | Generate Base64 shipment label and confirm shipment |
- PostnlShippingClient.Address
- PostnlShippingClient.Amount
- PostnlShippingClient.Contact
- PostnlShippingClient.Content
- PostnlShippingClient.Customer
- PostnlShippingClient.Customs
- PostnlShippingClient.Dimension
- PostnlShippingClient.Error
- PostnlShippingClient.GenerateLabel
- PostnlShippingClient.Group
- PostnlShippingClient.Message
- PostnlShippingClient.ProductOption
- PostnlShippingClient.Response
- PostnlShippingClient.ResponseLabels
- PostnlShippingClient.ResponseMergedLabels
- PostnlShippingClient.ResponseResponseShipments
- PostnlShippingClient.ResponseWarnings
- PostnlShippingClient.Shipments
All endpoints do not require authorization.