Skip to content

trackingmore100/tracking-sdk-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Trackingmore-CSHARP

The CSHARP SDK of Trackingmore API

Official document

Document

##Init

Api api = new Api("Your Api Key");

Quick Start

  • Put your ApiKey in the constructor of the Api class
  • All returns are in Json format String.
  • After instantiating the Api class, you can use its interface methods
  • You can set the sandbox of the Api instance to true to turn on the sandbox mode: api.sandbox=true;
  • Most Api params receive multiple tracking numbers

Get a list of the couriers in Trackingmore

string courier = "courier?lang=en";
response = api.doRequest(courier);
Console.WriteLine(response.Content.ReadAsStringAsync().Result);

Detect which couriers defined in your account match a tracking number

string post = "{ \"tracking_number\": \"EA152563254CN\" }";
response = api.doRequest("detect", post, "POST");
Console.WriteLine(response.Content.ReadAsStringAsync().Result);

Post trackings to your account

//Create single tracking numbers
string post = "{\"tracking_number\" => \"RP325552475CN\", \"carrier_code\" => \"china-post\"}";
//Create multiple tracking numbers
string post = "[{\"tracking_number\" => \"RP325552475CN\", \"carrier_code\" => \"china-post\"}",
    "{\"tracking_number\" => \"LZ448865302CN\", \"carrier_code\" => \"china-ems\"}]";
response = api.doRequest("create", post, "POST");
Console.WriteLine(response.Content.ReadAsStringAsync().Result);

Summary of Connection API Methods with all the api and Methods

        // Get realtime tracking results of a single tracking
        string post = "{\"tracking_number\": \"EA152563254CN\", \"carrier_code\": \"china-ems\"}";
        HttpResponseMessage response = api.doRequest("realtime", post, "POST");
        Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // count
        string count = "count?courier=1&limit=100&created_at_min=1521314361&created_at_max=1541314361";
        response = api.doRequest(count);
        Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // Get tracking results of a  tracking or List all trackings
        // string get = "get?page=1&limit=100&created_at_min=1521314361&created_at_max=1541314361";
        // response = api.doRequest(get);
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // Update Tracking item
        // response = api.doRequest("modifyinfo", post, "PUT");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // archive
        // response = api.doRequest("archive", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // Delete tracking item
        // response = api.doRequest("delete?num=EA152563254CN", "", "DELETE");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // create  tracking number
        // response = api.doRequest("create", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // manual update
        // response = api.doRequest("manualupdate", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // remote tracking
        // response = api.doRequest("remote", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // Get cost time iterm results
        // response = api.doRequest("transittime", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // detect a carriers by tracking number
        // string post = "{ \"num\": \"EA152563254CN\" }";
        // response = api.doRequest("detect", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // get all carriers
        // response = api.doRequest("carriers", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // Get status number
        // string status = "status?num=EA152563254CN";
        // response = api.doRequest(status);
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // Set number not update
        // response = api.doRequest("notupdate", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // Modify courier code
        // string post = "{\"num\": \"EA152563254CN\", \"express\": \"china-ems\", \"new_express\": \"china-post\"}";
        // response = api.doRequest("modifycourier", post, "PUT")
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // Get user info
        // response = api.doRequest("userinfo");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

        // // air real time track
        // response = api.doRequest("aircargo", post, "POST");
        // Console.WriteLine(response.Content.ReadAsStringAsync().Result);

Typical Server Responses

We will respond with one of the following status codes.

Code Type Message
200 Success Request response is successful
203 PaymentRequired API service is only available for paid account Please subscribe paid plan to unlock API services ul
204 No Content Request was successful, but no data returned Tracking NO. or target data possibly do not exist
400 Bad Request Request type error Please check the API documentation for the request type of this API
401 Unauthorized Authentication failed or has no permission Please check and ensure your API Key is correct
403 Bad Request Page does not exist Please check and ensure your link is correct ul
404 Not Found Page does not exist Please check and ensure your link is correct
408 Time Out Request timeout The official website did not return data, please try again later
411 Bad Request Specified request parameter length exceeds length limit Please check and ensure that the request parameters are of the required length
412 Bad Request Specified request parameter format doesn't meet requirements Please check and ensure that the request parameters are in the required format
413 Out limited The number of request parameters exceeds the limit Please check the API documentation for the limit of this API
417 Bad Request Missing request parameters or request parameters cannot be parsed Please check and ensure that the request parameters are complete and correctly formatted
421 Bad Request Some of required parameters are empty Some couriers need special parameters to track logistics information (Special Couriers)
422 Bad Request Unidentifiable courier code Please check and ensure that the courier code are correct(Courier code)
423 Bad Request Tracking No. already exists
424 Bad Request Tracking No. no exists Please use 「Create trckings」 API first to create trackings
429 Bad Request Exceeded API request limits, please try again later Please check the API documentation for the limit of this API
511 Server Error Server error Please contact us: service@trackingmore.org.
512 Server Error Server error Please contact us: service@trackingmore.org.
513 Server Error Server error Please contact us: service@trackingmore.org.