ParcelTrack API

Пример Python 

  • Класс API
    //www.parceltrack.ru/api-class_python

        Installation:
            1. Download this Class to desired location
            2. Fill in Api-Key in this Class in line protected ".'$apiKey'." = 'YOUR API KEY';
            3. Require this class in your project. Just like:
            require('/path/Parceltrack/class.php');


    Показать всех перевозчиков
    urlStr = ""
    requestData = ""
    result = tracker.parceltrack(requestData, urlStr, "carriers")
    
    Detect a carrier by tracking code
    urlStr = ""
    requestData = "{\"tracking_number\":\"EA152563251CN\"}"
    result = tracker.parceltrack(requestData, urlStr, "carriers/detect")
    
    Создать отправление для отслеживания
    urlStr = ''
    requestData ="{\"tracking_number\": \"BYS006086075\",\"carrier_code\":\"yanwen\"}"
    result = tracker.parceltrack(requestData, urlStr, "post")
    
    Получить информацию для одного отправления.
    urlStr = "/yanwen/BYS006086089"
    requestData =''
    result = tracker.parceltrack(requestData, urlStr, "codeNumberGet")
    
    Получить информацию об одном отправлении в режиме реального времени
    urlStr =''
    requestData ="{\"tracking_number\": \"LW505109082CN\",\"carrier_code\":\"china-ems\",\"destination_code\":\"United States\",\"tracking_ship_date\": \"deutsch-post\",\"tracking_postal_code\":\"postnl-3s\",\"specialNumberDestination\":\"postnl-3s\",\"order\":\"#123123\"}"
    result = tracker.parceltrack(requestData, urlStr, "realtime")
    
    Создать несколько отправлений для отслеживания.
    urlStr = ''
    requestData ="[{\"tracking_number\": \"EA152565241CN\",\"carrier_code\":\"china-ems\",\"title\":\"chase chen\",\"customer_name\":\"chase\",\"customer_email\":\"abc@qq.com\",\"order_id\":\"#123444\",\"order_create_time\":\"2018-05-20 12:00\",\"destination_code\":\"IL\",\"tracking_ship_date\":\"1525314361\",\"tracking_postal_code\":\"13ES20\",\"lang\":\"en\",\"logistics_channel\":\"4PX page\"},{\"tracking_number\": \"EA152563242CN\",\"carrier_code\":\"china-ems\",\"title\":\"chase chen\",\"customer_name\":\"chase\",\"customer_email\":\"abc@qq.com\",\"order_id\":\"#123444\",\"order_create_time\":\"2018-05-20 12:00\",\"destination_code\":\"IL\",\"tracking_ship_date\":\"1521314361\",\"tracking_postal_code\":\"13ES20\",\"lang\":\"en\",\"logistics_channel\":\"4PX page1\"}]""
    result = tracker.parceltrack(requestData, urlStr, "batch")
    
    Показать все отправления
    urlStr = "?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=EA152563254CN,UG586285221CN&orders=#123&lang=en"
    requestData =''
    result = tracker.parceltrack(requestData, urlStr, "get")
    
    Обновить отправление для отслеживания
    urlStr = "/yanwen/BYS006086092"
    requestData ="{\"title\": \"testtitle\",\"customer_name\":\"python test\",\"customer_email\":\"942632688@qq.com\",\"order_id\":\"#1234567\",\"logistics_channel\":\"chase chen python\",\"customer_phone\":\"+86 13873399982\",\"destination_code\":\"US\",\"status\":\"7\"}"
    result = tracker.parceltrack(requestData, urlStr, "codeNumberPut")
    
    Удалить отправление для отслеживания
    urlStr = "/wishpost/82196271478"
    requestData =''
    result = tracker.parceltrack(requestData, urlStr, "codeNumberDelete")
    
    Delete multiple tracking item
    urlStr = ""
    requestData = "[{\"tracking_number\":\"EA152563242CN\",\"carrier_code\":\"china-ems\"},{\"tracking_number\":\"EA152563254CN\",\"carrier_code\":\"china-ems\"}]"
    result = tracker.parceltrack(requestData, urlStr, "delete")
    
    Modify courier code
    urlStr = ""
    requestData = "{\"tracking_number\": \"EA152563242CN\",\"carrier_code\":\"dhl\",\"update_carrier_code\":\"china-ems\"}"
    result = tracker.parceltrack(requestData, urlStr, "update")
    
    get user info
    urlStr = ""
    requestData = ""
    result = tracker.parceltrack(requestData, urlStr, "getuserinfo")
    
    Get status number
    urlStr = ""
    requestData = ""
    result = tracker.parceltrack(requestData, urlStr, "getstatusnumber")
    
    Batch tags do not need to be updated
    urlStr = ""
    requestData = "[{\"tracking_number\":\"LK032051658CN\",\"carrier_code\":\"china-ems\"},{\"tracking_number\":\"EA166023092CN\",\"carrier_code\":\"china-ems\"}]"
    result = tracker.parceltrack(requestData, urlStr, "notupdate")
    
    Get remote iterm results
    urlStr = ""
    requestData = "[{\"country\":\"CN\",\"postcode\":\"400422\"},{\"country\":\"CN\",\"postcode\":\"412000\"}]"
    result = tracker.parceltrack(requestData, urlStr, "remote")
    
    Get cost time iterm results
    urlStr = ""
    requestData = "[{\"carrier_code\":\"dhl\",\"destination\":\"US\",\"original\":\"CN\"},{\"carrier_code\":\"dhl\",\"destination\":\"RU\",\"original\":\"CN\"}]"
    result = tracker.parceltrack(requestData, urlStr, "costtime")
    
    Updatemore Tracking item
    urlStr = ""
    requestData = "[{\"tracking_number\":\"RM131516216CN\",\"carrier_code\":\"china-post\",\"title\": \"testtitle\",\"customer_name\":\"python test\",\"customer_email\":\"942632688@qq.com\",\"order_id\":\"#123\",\"logistics_channel\":\"chase chen\",\"destination_code\":\"US\",\"status\":\"7\"},{\"tracking_number\":\"RM111516216CN\",\"carrier_code\":\"china-post\",\"title\": \"testtitle\",\"customer_name\":\"python test\",\"customer_email\":\"942632688@qq.com\",\"order_id\":\"#123\",\"logistics_channel\":\"chase chen\",\"destination_code\":\"US\",\"status\":\"7\"}]"
    result = tracker.parceltrack(requestData, urlStr, "updatemore")