|
1 |
| -# tracking-sdk-csharp |
2 |
| -Trackingmore API Csharp sdk |
| 1 | +Trackingmore-CSHARP |
| 2 | +================= |
| 3 | + |
| 4 | +The PHP SDK of Trackingmore API |
| 5 | +## Official document |
| 6 | + |
| 7 | +[Document](https://www.trackingmore.com/v3/api-index) |
| 8 | + |
| 9 | +##Init |
| 10 | +``` |
| 11 | +Api api = new Api("Your Api Key"); |
| 12 | +``` |
| 13 | + |
| 14 | + |
| 15 | +Quick Start |
| 16 | +-------------- |
| 17 | +- Put your ApiKey in the constructor of the Api class |
| 18 | +- All returns are in Json format String. |
| 19 | +- After instantiating the Api class, you can use its interface methods |
| 20 | +- You can set the sandbox of the Api instance to true to turn on the sandbox mode: <code>api.sandbox=true;</code> |
| 21 | +- Most Api params receive multiple tracking numbers |
| 22 | + |
| 23 | +**Get a list of the couriers in Trackingmore** |
| 24 | + |
| 25 | + string courier = "courier?lang=en"; |
| 26 | + response = api.doRequest(courier); |
| 27 | + Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 28 | + |
| 29 | +**Detect which couriers defined in your account match a tracking number** |
| 30 | + |
| 31 | + string post = "{ \"tracking_number\": \"EA152563254CN\" }"; |
| 32 | + response = api.doRequest("detect", post, "POST"); |
| 33 | + Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 34 | + |
| 35 | + |
| 36 | +**Post trackings to your account** |
| 37 | + |
| 38 | + //Create single tracking numbers |
| 39 | + string post = "{\"tracking_number\" => \"RP325552475CN\", \"carrier_code\" => \"china-post\"}"; |
| 40 | + //Create multiple tracking numbers |
| 41 | + string post = "[{\"tracking_number\" => \"RP325552475CN\", \"carrier_code\" => \"china-post\"}", |
| 42 | + "{\"tracking_number\" => \"LZ448865302CN\", \"carrier_code\" => \"china-ems\"}]"; |
| 43 | + response = api.doRequest("create", post, "POST"); |
| 44 | + Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 45 | + |
| 46 | +**Summary of Connection API Methods with all the api and Methods** |
| 47 | + |
| 48 | + // Get realtime tracking results of a single tracking |
| 49 | + string post = "{\"tracking_number\": \"EA152563254CN\", \"carrier_code\": \"china-ems\"}"; |
| 50 | + HttpResponseMessage response = api.doRequest("realtime", post, "POST"); |
| 51 | + Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 52 | + |
| 53 | + // count |
| 54 | + string count = "count?courier=1&limit=100&created_at_min=1521314361&created_at_max=1541314361"; |
| 55 | + response = api.doRequest(count); |
| 56 | + Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 57 | + |
| 58 | + // // Get tracking results of a tracking or List all trackings |
| 59 | + // string get = "get?page=1&limit=100&created_at_min=1521314361&created_at_max=1541314361"; |
| 60 | + // response = api.doRequest(get); |
| 61 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 62 | + |
| 63 | + // // Update Tracking item |
| 64 | + // response = api.doRequest("modifyinfo", post, "PUT"); |
| 65 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 66 | + |
| 67 | + // // archive |
| 68 | + // response = api.doRequest("archive", post, "POST"); |
| 69 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 70 | + |
| 71 | + // // Delete tracking item |
| 72 | + // response = api.doRequest("delete?num=EA152563254CN", "", "DELETE"); |
| 73 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 74 | + |
| 75 | + // // create tracking number |
| 76 | + // response = api.doRequest("create", post, "POST"); |
| 77 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 78 | + |
| 79 | + // // manual update |
| 80 | + // response = api.doRequest("manualupdate", post, "POST"); |
| 81 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 82 | + |
| 83 | + // // remote tracking |
| 84 | + // response = api.doRequest("remote", post, "POST"); |
| 85 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 86 | + |
| 87 | + // // Get cost time iterm results |
| 88 | + // response = api.doRequest("transittime", post, "POST"); |
| 89 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 90 | + |
| 91 | + // // detect a carriers by tracking number |
| 92 | + // string post = "{ \"num\": \"EA152563254CN\" }"; |
| 93 | + // response = api.doRequest("detect", post, "POST"); |
| 94 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 95 | + |
| 96 | + // // get all carriers |
| 97 | + // response = api.doRequest("carriers", post, "POST"); |
| 98 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 99 | + |
| 100 | + // // Get status number |
| 101 | + // string status = "status?num=EA152563254CN"; |
| 102 | + // response = api.doRequest(status); |
| 103 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 104 | + |
| 105 | + // // Set number not update |
| 106 | + // response = api.doRequest("notupdate", post, "POST"); |
| 107 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 108 | + |
| 109 | + // // Modify courier code |
| 110 | + // string post = "{\"num\": \"EA152563254CN\", \"express\": \"china-ems\", \"new_express\": \"china-post\"}"; |
| 111 | + // response = api.doRequest("modifycourier", post, "PUT") |
| 112 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 113 | + |
| 114 | + // // Get user info |
| 115 | + // response = api.doRequest("userinfo"); |
| 116 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 117 | + |
| 118 | + // // air real time track |
| 119 | + // response = api.doRequest("aircargo", post, "POST"); |
| 120 | + // Console.WriteLine(response.Content.ReadAsStringAsync().Result); |
| 121 | + |
| 122 | +## Typical Server Responses |
| 123 | + |
| 124 | +We will respond with one of the following status codes. |
| 125 | + |
| 126 | +Code|Type | Message |
| 127 | +----|--------------|------------------------------- |
| 128 | +200 | <code>Success</code>| Request response is successful |
| 129 | +203 | <code>PaymentRequired</code>| API service is only available for paid account Please subscribe paid plan to unlock API services ul |
| 130 | +204 | <code>No Content</code>| Request was successful, but no data returned Tracking NO. or target data possibly do not exist |
| 131 | +400 | <code>Bad Request</code>| Request type error Please check the API documentation for the request type of this API |
| 132 | +401 | <code>Unauthorized</code>| Authentication failed or has no permission Please check and ensure your API Key is correct |
| 133 | +403 | <code>Bad Request</code>| Page does not exist Please check and ensure your link is correct ul |
| 134 | +404 | <code>Not Found</code>| Page does not exist Please check and ensure your link is correct |
| 135 | +408 | <code>Time Out</code>| Request timeout The official website did not return data, please try again later |
| 136 | +411 | <code>Bad Request</code>| Specified request parameter length exceeds length limit Please check and ensure that the request parameters are of the required length |
| 137 | +412 | <code>Bad Request</code>| Specified request parameter format doesn't meet requirements Please check and ensure that the request parameters are in the required format |
| 138 | +413 | <code>Out limited</code>| The number of request parameters exceeds the limit Please check the API documentation for the limit of this API |
| 139 | +417 | <code>Bad Request</code>| Missing request parameters or request parameters cannot be parsed Please check and ensure that the request parameters are complete and correctly formatted |
| 140 | +421 | <code>Bad Request</code>| Some of required parameters are empty Some couriers need special parameters to track logistics information (Special Couriers) |
| 141 | +422 | <code>Bad Request</code>| Unidentifiable courier code Please check and ensure that the courier code are correct(Courier code) |
| 142 | +423 | <code>Bad Request</code>| Tracking No. already exists |
| 143 | +424 | <code>Bad Request</code>| Tracking No. no exists Please use 「Create trckings」 API first to create trackings |
| 144 | +429 | <code>Bad Request</code>| Exceeded API request limits, please try again later Please check the API documentation for the limit of this API |
| 145 | +511 | < code>Server Error</ code>| Server error Please contact us: [email protected]. |
| 146 | +512 | < code>Server Error</ code>| Server error Please contact us: [email protected]. |
| 147 | +513 | < code>Server Error</ code>| Server error Please contact us: [email protected]. |
0 commit comments