Tracking Api for Fedex and Ups [Closed]

Tracking Api for Fedex and Ups [Closed]

Is there any JavaScript API available for tracking Fedex and UPS packages?

1

3 Answers

I googled for something like this but couldn't find anything. Then I decided to do it server side in ROR.

Here it is how to get UPS and Fedex xml request and response from their test servers.

For Fedex:

track_no = '111111111111'  # This is a test tracking number

# This XML Request body for fedex
xml_req = 

"<TrackRequest xmlns='
                <Password>YOUR_ACC_PASSWORD</Password></UserCredential></WebAuthenticationDetail><ClientDetail>
                <AccountNumber>YOUR_ACC_NUMBER</AccountNumber><MeterNumber>YOUR_ACC_METER_NUMBER</MeterNumber></ClientDetail>
                <TransactionDetail><CustomerTransactionId>ActiveShipping</CustomerTransactionId></TransactionDetail>
                <Version><ServiceId>trck</ServiceId><Major>3</Major><Intermediate>0</Intermediate><Minor>0</Minor></Version>
                <PackageIdentifier><Value>#{track_no}</Value><Type>TRACKING_NUMBER_OR_DOORTAG</Type></PackageIdentifier>
                <IncludeDetailedScans>1</IncludeDetailedScans></TrackRequest>"

path = ""

#this url connects to the test server of fedex
# for live server url is:""

url = URI.parse(path)
http = Net::HTTP.new(url.host,url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

response =  http.post(url.path, xml_req)
response_body = response.body
res = response_body.gsub(/<(\/)?.*?\:(.*?)>/, '<\1\2>')
hash = Hash.from_xml(res.to_s)

And that's it! You will get response in hash variable, I converted xml response in to Hash because we can easily use Hash object at our view to display response data.

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.