Use Node.js to track Royal Mail shipments with Royal Mail Tracking API.
- Real-time Royal Mail tracking.
- Batch Royal Mail tracking.
- Other features to manage your Royal Mail tracking.
Installation is easy:
$ npm install trackingmore-sdk-nodejs
Get the API key:
To use this API, you need to generate your API key.
- Click here to access TrackingMore admin.
-
Go to the "Developer" section.
-
Click "Generate API Key".
-
Give a name to your API key, and click "Save" .
Then, start to track your Royal Mail shipments.
Create a tracking (Real-time tracking):
const TrackingMore = require('trackingmore-sdk-nodejs')
const key = 'your api key'
const trackingmore = new TrackingMore(key)
const params = {
'tracking_number': 'RF423511785GB',
'courier_code': 'royal-mail',
'order_number': '',
'customer_name': '',
'title': '',
'language': 'en',
'note': 'test Order'
}
trackingmore.trackings.createTracking(params)
.then(result => console.log(result))
.catch(e => console.log(e))
Create trackings (Max. 40 tracking numbers create in one call):
const TrackingMore = require('trackingmore-sdk-nodejs')
const key = 'your api key'
const trackingmore = new TrackingMore(key)
const params = [{
'tracking_number': 'FL356951328GB',
'courier_code':'royal-mail'
},{
'tracking_number': 'KL698957554GB',
'courier_code':'royal-mail'
}]
trackingmore.trackings.batchCreateTrackings(params)
.then(result => console.log(result))
.catch(e => console.log(e))
Get status of the shipment:
const TrackingMore = require('trackingmore-sdk-nodejs')
const key = 'your api key'
const trackingmore = new TrackingMore(key)
# Perform queries based on various conditions
const params = [{
'tracking_number': 'FL356951328GB',
'courier_code':'royal-mail'
},{
'tracking_number': 'KL698957554GB',
'courier_code':'royal-mail'
}]
trackingmore.trackings.batchCreateTrackings(params)
.then(result => console.log(result))
.catch(e => console.log(e))
Update a tracking by ID:
const TrackingMore = require('trackingmore-sdk-nodejs')
const key = 'your api key'
const trackingmore = new TrackingMore(key)
const params = {
'customer_name': 'New name',
'note':'New test order note'
}
const idString = "9a134772fec0a75ba36ed8162151eb87"
trackingmore.trackings.updateTrackingByID(idString, params)
.then(result => console.log(result))
.catch(e => console.log(e))