Trackru API

По любым возникшим вопросам, касающимся Апи интеграции, пишите на нашу почту: [email protected]

Пример Ruby 

  • Классы PHP
    //www.trackru.ru/api-class_ruby.html

        Монтаж:
            1. Скачайте данный класс в нужное место,
            2. В данной строке класса необходимо ввести Api-key protected $apiKey = 'YOUR API KEY';
            3. Укажите этот класс в вашем проекте. Как:
            require('/path/Trackru/class.php');


    Список служб доставки
    url="http://api.trackru.ru/v1/carriers/"
    postData = ""
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"GET")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Определить перевозчика по коду отслеживания
    url="http://api.trackru.ru/v1/carriers/detect"
    postData = {"tracking_number":"EA152563251CN"}
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Список всех отслеживаний
    url="http://api.trackru.ru/v1/trackings/get?page=1&limit=100&created_at_min=1521314361&created_at_max=1541314361&update_time_min=1521314361&update_time_max=1541314361&order_created_time_min=1521314361&order_created_time_max=1541314361&numbers=BYS006086078&orders=#123&lang=en"
    postData = ""
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"GET")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Создать элемент отслеживания
    url="http://api.trackru.ru/v1/trackings/post"
    postData = {"tracking_number":"BYS006086078","carrier_code":"yanwen","title":"chase chen","customer_name":"chase","customer_email":"[email protected]","order_id":"#123","order_create_time":"1521314361","destination_code":"IL","tracking_ship_date":"1521314361","tracking_postal_code":"13ES20","lang":"en","logistics_channel":"4PX挂号小包"}
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Создать мульти-отслеживание
    url="http://api.trackru.ru/v1/trackings/batch"
    postData = [
       {"tracking_number": "BYS006086087","carrier_code":"yanwen","title":"chase chen","customer_name":"chase","customer_email":"[email protected]","order_id":"#123","order_create_time":"2018-05-11 12:00","destination_code":"IL","tracking_ship_date":"1521314361","tracking_postal_code":"13ES20","lang":"en","logistics_channel":"4545454"},
       {"tracking_number": "BYS006086076","carrier_code":"yanwen","title":"chase chen","customer_name":"chase","customer_email":"[email protected]","order_id":"#123","order_create_time":"2018-05-10 12:00","destination_code":"IL","tracking_ship_date":"1521314361","tracking_postal_code":"13ES20","lang":"en","logistics_channel":"4PX挂号小包"}
    ]
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Получить результаты отслеживания для конкретного отправления
    url="http://api.trackru.ru/v1/trackings/yanwen/RX478151565DE"
    postData =""
    tracker  = Trackru.new()
    res      = tracker.tracker(url,postData,"GET")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Обновить отслеживание
    url="http://api.trackru.ru/v1/trackings/yanwen/BYS006086079"
    postData = {"title":"ruby test","customer_name":"test","customer_email":"[email protected]","order_id":"#1234567","logistics_channel":"4PX挂号小包"}
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"PUT")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Удалить отслеживание
    url="http://api.trackru.ru/v1/trackings/yanwen/RX478151548DE"
    postData =""
    tracker  = Trackru.new()
    res      = tracker.tracker(url,postData,"DELETE")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Получить результаты отслеживания на настоящий момент для единичного отслеживания
    url="http://api.trackru.ru/v1/trackings/realtime"
    postData = {"tracking_number": "RO454978691CN","carrier_code":"china-post","destination_code": "United States","tracking_ship_date":"deutsch-post","tracking_postal_code":"postnl-3s","specialNumberDestination":"postnl-3s","order":"#123123","order_create_time":"1521314361","lang":"en"}
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Удалить несколько элементов отслеживания
    url="http://api.trackru.ru/v1/trackings/delete"
    postData = [{"tracking_number":"BYS006086077","carrier_code":"yanwen"},{"tracking_number":"BYS006086088","carrier_code":"yanwen"}]
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Изменить код курьера
    url="http://api.trackru.ru/v1/trackings/update"
    postData = {"tracking_number":"BYS006086077","carrier_code":"dhl","update_carrier_code":"yanwen"}
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    получить информацию о пользователе
    url="http://api.trackru.ru/v1/trackings/getuserinfo"
    postData = ""
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"GET")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Получить номер статуса
    url="http://api.trackru.ru/v1/trackings/getstatusnumber"
    postData = ""
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"GET")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Пакетные теги обновлять не нужно
    url="http://api.trackru.ru/v1/trackings/notupdate"
    postData = [
       {"tracking_number":"BYS006086077","carrier_code":"yanwen"},
       {"tracking_number":"BYS006086088","carrier_code":"yanwen"}
    ]
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Получить результаты удаленного итерм
    url="http://api.trackru.ru/v1/trackings/remote"
    postData = [{"country":"CN","postcode":"400422","company":"dhl"},{"country":"CN","postcode":"412000","company":"dhl"}]
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    Получить итоговые результаты
    url="http://api.trackru.ru/v1/trackings/costtime"
    postData = [{"carrier_code":"dhl","destination":"US","original":"CN"},{"carrier_code":"dhl","destination":"RU","original":"CN"}]
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"
    
    ОбновлениеДля отслеживания
    url="http://api.trackru.ru/v1/trackings/updatemore"
    postData =[{"tracking_number":"BYS006086087","carrier_code":"yanwen","title":"chase chen111","customer_name":"chaseddd","customer_email":"[email protected]","order_id":"#123457777774","destination_code":"IL","status":"4","logistics_channel":"4PX挂号小包"},{"tracking_number":"BYS006086076","carrier_code":"yanwen","title":"chase chen222","customer_name":"chase dsd","customer_email":"[email protected]","order_id":"#1234577777","destination_code":"IL","status":"4","logistics_channel":"4PX挂号小包"}]
    tracker = Trackru.new()
    res = tracker.tracker(url,postData,"POST")
    puts "Response #{res.code} #{res.message}: #{res.body}"