trackingmore-sdk-nodejs

1.0.8 • Public • Published

TrackingMore-sdk-nodejs

node.js SDK for TrackingMore API

Contact: manage@trackingmore.org

Official document

Document

Index

  1. Installation
  2. Testing
  3. SDK
    1. Couriers
    2. Trackings
    3. Air Waybill

Installation

npm install trackingmore-sdk-nodejs

Quick Start

const TrackingMore = require('trackingmore-sdk-nodejs')
const key = 'you api key'
const trackingmore = new TrackingMore(key)

trackingmore.couriers.getAllCouriers()
    .then(result => console.log(result))
    .catch(e =>  console.error('An error occurred:', e.message))

Testing

npm run test or npm test

Error handling

Simply add a try-catch block

// Get all couriers (couriers/all)
trackingmore.couriers.getAllCouriers()
    .then(result => console.log(result))
    .catch(e =>  console.error('An error occurred:', e.message))

Couriers

Return a list of all supported couriers.

https://api.trackingmore.com/v4/couriers/all

trackingmore.couriers.getAllCouriers()
    .then(result => console.log(result))
    .catch(e => console.log(e))
Return a list of matched couriers based on submitted tracking number.

https://api.trackingmore.com/v4/couriers/detect

const params = {'tracking_number': '9400111899562537624326'}
trackingmore.couriers.detect(params)
    .then(result => console.log(result))
    .catch(e => console.log(e))

Trackings

Create a tracking.

https://api.trackingmore.com/v4/trackings/create

const params = {
    'tracking_number': '9400111899562537624326',
    'courier_code': 'usps',
    'order_number': '',
    'customer_name': '',
    'title': '',
    'language': 'en',
    'note': 'test Order'
}
trackingmore.trackings.createTracking(params)
    .then(result => console.log(result))
    .catch(e => console.log(e))
Get tracking results of multiple trackings.

https://api.trackingmore.com/v4/trackings/get

const params = {
    'tracking_numbers': '9400111899562539126562,9400111899562537624656',
    'courier_code': 'usps',
    'created_date_min': '2023-08-23T06:00:00+00:00',
    'created_date_max': '2023-09-05T07:20:42+00:00',
}
trackingmore.trackings.getTrackingResults(params)
    .then(result => console.log(result))
    .catch(e => console.log(e))
Create multiple trackings (Max. 40 tracking numbers create in one call).

https://api.trackingmore.com/v4/trackings/batch

const params = [{
    'tracking_number': '9400111899562537680047',
    'courier_code':'usps'
},{
    'tracking_number': '9400111899562537680048',
    'courier_code':'usps'
}]
trackingmore.trackings.batchCreateTrackings(params)
.then(result => console.log(result))
.catch(e => console.log(e))
Update a tracking by ID.

https://api.trackingmore.com/v4/trackings/update/{id}

const params = {
    'customer_name': 'New name',
    'note':'New test order note'
}
const idString = "9a135b15b5d983e1d8950d99022db0c7"
trackingmore.trackings.updateTrackingByID(idString, params)
.then(result => console.log(result))
.catch(e => console.log(e))
Delete a tracking by ID.

https://api.trackingmore.com/v4/trackings/delete/{id}

const idString = "9a135b15b5d983e1d8950d99022db0c7"
trackingmore.trackings.deleteTrackingByID(idString)
.then(result => console.log(result))
.catch(e => console.log(e))
Retrack expired tracking by ID.

https://api.trackingmore.com/v4/trackings/retrack/{id}

const idString = "99f4ed7fc73aa83fe68fd69ab6458b28"
trackingmore.trackings.retrackTrackingByID(idString)
.then(result => console.log(result))
.catch(e => console.log(e))

Air Waybill

Create an air waybill.

https://api.trackingmore.com/v4/awb

const params = {
    'awb_number': '235-69030430',
}
trackingmore.airWaybills.createAnAirWayBill(params)
.then(result => console.log(result))
.catch(e => console.log(e))

Response Code

Trackingmore uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g. a required parameter was missing, a charge failed, etc.), and codes in the 5xx range indicate an TrackingMore's server error.

Http CODE META CODE TYPE MESSAGE
200 200 Success Request response is successful
400 400 BadRequest Request type error. Please check the API documentation for the request type of this API.
400 4101 BadRequest Tracking No. already exists.
400 4102 BadRequest Tracking No. no exists. Please use 「Create a tracking」 API first to create shipment.
400 4103 BadRequest You have exceeded the shipment quantity of API call. The maximum quantity is 40 shipments per call.
400 4110 BadRequest The value of tracking_number is invalid.
400 4111 BadRequest Tracking_number is required.
400 4112 BadRequest Invalid Tracking ID.
400 4113 BadRequest Retrack is not allowed. You can only retrack an expired tracking.
400 4120 BadRequest The value of courier_code is invalid.
400 4121 BadRequest Cannot detect courier.
400 4122 BadRequest Missing or invalid value of the special required fields for this courier.
400 4130 BadRequest The format of Field name is invalid.
400 4160 BadRequest The awb_number is required or invaild format.
400 4161 BadRequest The awb airline does not support yet.
400 4190 BadRequest You are reaching the maximum quota limitation, please upgrade your current plan.
401 401 Unauthorized Authentication failed or has no permission. Please check and ensure your API Key is correct.
403 403 Forbidden Access prohibited. The request has been refused or access is not allowed.
404 404 NotFound Page does not exist. Please check and ensure your link is correct.
429 429 TooManyRequests Exceeded API request limits, please try again later. Please check the API documentation for the limit of this API.
500 511 ServerError Server error. Please contact us: service@trackingmore.org.
500 512 ServerError Server error. Please contact us: service@trackingmore.org.
500 513 ServerError Server error. Please contact us: service@trackingmore.org.

Readme

Keywords

Package Sidebar

Install

npm i trackingmore-sdk-nodejs

Weekly Downloads

21

Version

1.0.8

License

MIT

Unpacked Size

28.7 kB

Total Files

11

Last publish

Collaborators

  • trackingmore