Skip to content

Latest commit

 

History

History
109 lines (76 loc) · 3.2 KB

dhl-ecommerce-tracking-api-ruby.md

File metadata and controls

109 lines (76 loc) · 3.2 KB

DHL eCommerce Tracking API - Node.js

Use Node.js to track DHL eCommerce shipments with DHL eCommerce Tracking API.

Features

  • Real-time DHL eCommerce tracking.
  • Batch DHL eCommerce tracking.
  • Other features to manage your DHL eCommerce tracking.

Installation

Installation is easy:

gem install trackingmore

Quick Start

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 DHL eCommerce shipments.

Usage

Create a tracking (Real-time tracking):

  require  'trackingmore'

  TrackingMore.api_key = 'your api key'
  
  begin
    params  = {"tracking_number" => "4982891432","courier_code"=>"dhlglobalmail"}
    response = TrackingMore::Tracking.create_tracking(params)
    puts response
  rescue TrackingMore::TrackingMoreException => e
    puts "Caught Custom Exception: #{e.message}"
  rescue StandardError => e
    puts "Caught Standard Error: #{e.message}"
  end

Create trackings (Max. 40 tracking numbers create in one call):

require  'trackingmore'

TrackingMore.api_key = 'your api key'

begin
  params  = [{"tracking_number" => "92632903279511573030094832","courier_code"=>"dhlglobalmail"},{"tracking_number" => "92642903289511563030094932","courier_code"=>"dhlglobalmail"}]
  response = TrackingMore::Tracking.batch_create_trackings(params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
  puts "Caught Standard Error: #{e.message}"
end

Get status of the shipment:

require  'trackingmore'

TrackingMore.api_key = 'your api key'

begin
  # Perform queries based on various conditions
  # params  = {"courier_code"=>"dhlglobalmail"}
  # params  = {"tracking_numbers" => "2967650674,8307478620","courier_code"=>"dhlglobalmail"}
  params  = {"created_date_min" => "2023-08-23T14:00:00+08:00","created_date_max"=>"2023-08-23T15:04:00+08:00"}
  response = TrackingMore::Tracking.get_tracking_results(params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
  puts "Caught Standard Error: #{e.message}"
end

Update a tracking by ID:

require  'trackingmore'

TrackingMore.api_key = 'your api key'

begin
  params  = {"customer_name" => "New name","note"=>"New tests order note"}
  id_string = '9b42b6bbbb647005acf63b5ed64f22f0'
  response = TrackingMore::Tracking.update_tracking_by_id(id_string, params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
  puts "Caught Standard Error: #{e.message}"
end