Giter Site home page Giter Site logo

delivery-tracker's Introduction

delivery-tracker

version download status status Standard - JavaScript Style Guide

delivery-tracker is delivery tracking library for Node.js

Courier List

Name Contributor Link
Korea Post @egg- http://www.koreapost.go.kr/
Ecargo @egg- http://ecargo.asia/script/users/main.php
FedEx @egg- https://www.fedex.com/
Australia Post @egg- https://auspost.com.au/
Pantos @egg- http://www.epantos.com/
Rincos @egg- http://www.rincos.co.kr/
Royal Mail @egg- http://www.royalmail.com/
USPS @egg- https://www.usps.com/
CJ Korea Express (Korea) @egg- http://cjkoreaexpress.co.kr/ (https://www.doortodoor.co.kr)
POS Laju @egg- http://www.poslaju.com.my
Yello Express @egg- https://www.yello-express.com
EFS @egg- http://efs.asia/
UPS @egg- https://www.ups.com
TNT @egg- https://www.tnt.com
CESCO @egg- https://www.cesco-logistics.com/
XPOST @egg- https://www.xpost.ph/
KERRYTHAI @egg- https://th.kerryexpress.com
SICEPAT @egg- http://sicepat.com/
XIOExpress @egg- https://xioexpress.com/
eParcel @egg- https://eparcel.kr/
LBC @egg- https://www.lbcexpress.com/
J&T (PH) @egg- https://www.jtexpress.ph/
DHL @carstenschwede https://www.dhl.com/
Canada Post @egg- https://www.canadapost-postescanada.ca/
PAXEL @egg- https://paxel.co/

Installation

$ npm install delivery-tracker

Usage

var tracker = require('delivery-tracker')
var courier = tracker.courier(tracker.COURIER.KOREAPOST.CODE)

courier.trace('TRACE_NUMBER', function (err, result) {
  console.log(result)
})

Command Line

$ npm install -g delivery-tracker
$ delivery-tracker -h

Usage: index [options] <tracecode>

  Options:

    -h, --help               output usage information
    -c, --courier <courier>  Courier Namespace
    -k, --apikey <apikey>  Courier API key

$ delivery-tracker -c EMS EBXXXXXXXXXKR

Response

Attribute Type Description
courier Courier Object courier information
number String tracking number
status String delivery status
checkpoints Array of Checkpoint Object Array of the checkpoint information.

Courier Object

Attribute Type Description
code String Unique code of courier.
name String Courier name

Checkpoint Object

Attribute Type Description
courier Courier Object courier information
location String Location info of the checkpoint provided by the courier.
message String Checkpoint message
time String The date and time of the checkpoint provided by the courier. The values can be:
Empty string,
YYYY-MM-DD,
YYYY-MM-DDTHH:mm:ss
YYYY-MM-DDTHH:mm:ss+Timezone

CODE

COURIER

tracker.COURIER.{NAMESPACE}

NAMESPACE CODE NAME
KOREAPOST koreapost Korea Post
ECARGO ecargo Ecargo
FEDEX fedex FedEx
AUSPOST auspost Australia Post
PANTOS pantos Pantos
RINCOS rincos Rincos
ROYALMAIL royalmail Royal Mail
USPS usps USPS
CJKOREAEXPRESS cjkoreaexpress CJ Korea Express
POSLAJU poslaju POS Laju
YELLOEXPRESS yelloexpress Yello Express
EFS efs EFS
UPS ups UPS
TNT tnt TNT
CESCO cesco CESCO
XPOST xpost XPOST
KERRYTHAI kerrythai KERRYTHAI
SICEPAT sicepat SICEPAT
XIOEXPRESS xioexpress XIOExpress
EPARCEL eparcel eParcel
LBC lbc LBC
JNT jnt J&T
DHL dhl DHL
CANADAPOST canadapost Canada Post
PAXEL paxel Paxel

STATUS

tracker.STATUS.{CODE}

Code Value Description
INFO_RECEIVED InfoReceived The carrier received a request from the shipper and wants to start shipping.
PENDING Pending New pending shipment to track or a new shipment without tracking information added.
IN_TRANSIT InTransit The carrier has received or received the carrier. Shipment is in progress.
DELIVERED Delivered The shipment was successfully delivered.
RETURNED Returned The shipment was returned.
EXCEPTION Exception Custom hold, undeliverable, shipper has shipped or shipped an exception.
FAIL_ATTEMPT FailAttempt The courier tried to send but failed, but usually reminds and tries again.

ERROR

tracker.STATUS.{CODE}

Code Value Description
UNKNOWN -1 Unknow error
NOT_SUPPORT_SHIPMENT 20 shipment does not support.
INVALID_NUMBER 10 invalid trace number.
INVALID_NUMBER_LENGTH 11 invalid trace number.
INVALID_NUMBER_HEADER 12 invalid trace number.
INVALID_NUMBER_COUNTRY 13 invalid trace number.

Sample

// KOREAPOST
{
  "courier": {
    "code": "koreapost",
    "name": "Korea Post"
  },
  "number": "EBCOMPLETE0KR",
  "status": "Delivered",
  "checkpoints": [
    {
      "courier": {
        "code": "koreapost",
        "name": "Korea Post"
      },
      "location": "MY4332",
      "message": "Delivery complete\nRecipient : K*NG()\nResult : Delivery complete",
      "time": "2016-07-04T11:40:00"
    },
    // ...
  ]
}

// FEDEX
{
  "courier": {
    "code": "fedex",
    "name": "FedEx"
  },
  "number": "DELIVEREDNUM",
  "status": "Delivered",
  "checkpoints": [
    {
      "courier": {
        "code": "fedex",
        "name": "FedEx"
      },
      "location": "SOUTH JORDAN, UT",
      "message": "Package delivered by U.S. Postal Service to addressee",
      "status": "Delivered",
      "time": "2016-12-14T13:17:00-07:00"
    },
    // ...
  ]
}

// PANTOS
{
  "courier": {
    "code": "pantos",
    "name": "Pantos"
  },
  "number": "DELIVEREDNUM-AUSPOST",
  "status": "Delivered",
  "checkpoints": [
    {
      "courier": {
        "code": "auspost",
        "name": "Australia Post"
      },
      "location": "Canning Vale, WA",
      "message": "Delivered",
      "status": "Delivered",
      "time": "2017-01-03T15:24:00+08:00"
    },
    // ...
    {
      "courier": {
        "code": "pantos",
        "name": "Pantos"
      },
      "location": "KRICN",
      "message": "Pick-Up (Pick-Up)",
      "status": "InfoReceived",
      "time": "2016-12-20T11:25"
    }
  ]
}

Test

Test with mocha

$ grunt

like watch

$ grunt watch

Contributing

Bug reports and pull requests are welcome on Github at https://github.com/egg-/delivery-tracker

  1. Fork it
  2. Create your feature branch.
  3. Commit your changes.
  4. Push to the branch.
  5. Create a new Pull Request.

Release History

See the CHANGELOG.md

License

delivery-tracker is licensed under the MIT license.

delivery-tracker's People

Contributors

bradlee96 avatar carstenschwede avatar egg- avatar mindsolve avatar nanthanwa avatar qcasey avatar shrinath-bidchat avatar zinthose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

delivery-tracker's Issues

cb is not a function

Getting this every time I make a call for USPS:


          cb(tracker.error(e.message))
          ^

TypeError: cb is not a function

How do I solve it?

Here's my code:

const tracker = require('delivery-tracker')

const uspsCourier = tracker.courier( tracker.COURIER.USPS.CODE )

exports.upsTrackingNumber = async ( req, res ) =>
{
    let a = {}
    let { tracking_number } = req.body
    try {
        upsCourier.trace( { trace_number: tracking_number }, function (err, result) {
            if ( err ) { log( `err: `, err ) }
            console.log(result)
            res.json( result )
          } )
        
    } catch ( e ) {
        log( `upsTrackingNumber e: `, e )
        res.status( 400 ).json( { error: e } )
    }
}

Full error;

C:\Users\User\Desktop\project\backend\node_modules\delivery-tracker\lib\courier\usps.js:100
          cb(tracker.error(e.message))
          ^

TypeError: cb is not a function
    at Request._callback (C:\Users\User\Desktop\project\backend\node_modules\delivery-tracker\lib\courier\usps.js:100:11)
    at Request.self.callback (C:\Users\User\Desktop\project\backend\node_modules\request\request.js:185:22)
    at Request.emit (node:events:390:28)
    at Request.emit (node:domain:475:12)
    at Request.<anonymous> (C:\Users\User\Desktop\project\backend\node_modules\request\request.js:1154:10)
    at Request.emit (node:events:390:28)
    at Request.emit (node:domain:475:12)
    at IncomingMessage.<anonymous> (C:\Users\User\Desktop\project\backend\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (node:events:509:28)
    at IncomingMessage.emit (node:events:402:35)
    at IncomingMessage.emit (node:domain:475:12)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Bad error handling and crash

In fedex.js line 101 looks like this

var results = parser.trace(body.TrackPackagesResponse.packageList);

and you do not handle the res correctly. request does not return error if the request response was actually an http error. and because of that you are not handling all error from the provider.

For example, fedex sometimes returns 403 with body null on multiple requests, which is a sync crash in line 101, meanwhile, it should return the error in res.

The delivery-tracker is not work with UPS.

Dear,
From 1 day ago. I see, our's library is not working for requests to UPS service to get tracking.
I was tested with the same tracking number on the UPS website that is response result ok. But that does not work with our system.
What happened with our's system? Did the UPS have any update and we out an update?
My test: with new version 2.7.0
delivery-tracker -c UPS 1Z4566F5NT41188xxx
Many Thanks

Feature Request: Make library usable within browser

It would be useful to have this library available directly within the browser.
Has this been considered already? Are there any methods that can't be replicated in the browser?

Based on a quick skim I would imagine that replacing request and require with corresponding fetch calls might be sufficient. (Other option would be to rollup all require calls for the courier inclusions in one chunk)

Cannot run in browser (React code)

When attempting to track a FedEx package in my React code, I received:

POST https://www.fedex.com/trackingCal/track 403 (Forbidden)

And:

Access to fetch at 'https://www.fedex.com/trackingCal/track' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Is there any way to set the CORS mode to no-cors when running in a browser? Or was the module not meant to be used in a browser? Is the 403 error related, or incidental?

Feature Request: Return raw response for custom parsing

First of all, thankyou for creating this package. It has helped me tons. I only require Fedex tracking and fedex docs are super confusing, so this has been a lifesaver.

I'd like to request a feature to return raw response for tracking. For eg; Fedex gives tons of data about shipment but the returned data is just an array of 'scans'. It'd be useful if we could set a flag to return all data.

modernize module (move to ts and change deprecated deps)

some things to do with this project to modernize it:

  • convert to typescript to benefit from intellisense and autocomplete in IDEs
  • replace request library with axios since request is depracated

I can open a PR to do the following changes, but since it's a big change, I want to check with the author that this is something that he wants to change. If you guys do want this, I'll open a PR to fix both issues

Questions on API limitations

This is just a functionality question but we're looking for a general purpose api for tracking shipments to integrate into our application. This packages is exactly what we were looking for. But have you found any limitations to the APIs you are hitting? ie Daily/Hourly frequency caps

UPS invalid dates

All of the result.checkpoints.time fields returned by UPS are set to 'Invalid Date'.

Canada Post Tracking

Just wondering if there's plan for adding Canada Post tracking.
They have "unofficial" JSON APIs for tracking multiple packages summary and single package details:

GET https://www.canadapost-postescanada.ca/track-reperage/rs/track/json/package?pins=
GET https://www.canadapost-postescanada.ca/track-reperage/rs/track/json/package/

Would love to take a look and help out or make a full request.

UPS not working

Looks like the response here says:

The response body for the UPS request is: body: '{"unauthorized":401}'

Acquiring Test Tracking Numbers

Hello,

Thanks for the great project, it’s really helping with a project that I’m working on. I’m interested in adding another courier to this, which I’m fully capable of doing myself, but I’m wondering how you go about getting test Tracking IDs to test with. I have a few parcels with this courier, but I doubt they could reach all needed test cases. Would I have any luck contacting the courier directly for this?

Courier: https://asendiausa.com

USPS no longer working

I'm using version 2.7.2 with USPS tracking numbers, even if valid on the USPS website seem to only return the response
{ code: 10, message: 'invalid trace number.' }

The issue started seemingly 2022-09-19 and continues to this morning. Perhaps there is a change or restriction upstream?

TypeScript typings

Hey! I think TypeScript typings would be very useful for me and other TypeScript users.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.