Skip to content

Commit bca4be7

Browse files
committed
Modify readme file information
1 parent f0627dd commit bca4be7

File tree

1 file changed

+228
-1
lines changed

1 file changed

+228
-1
lines changed

README.md

Lines changed: 228 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,231 @@
11
trackingmore-sdk-python
22
=================
33

4-
The Python SDK of
4+
The Python SDK of Trackingmore API
5+
6+
Contact: <manage@trackingmore.org>
7+
8+
## Official document
9+
10+
[Document](https://www.trackingmore.com/docs/trackingmore/d5ac362fc3cda-api-quick-start)
11+
12+
Supported Python Versions
13+
=========================
14+
15+
- 3.7
16+
- 3.8
17+
- 3.9
18+
- 3.10
19+
- pypy3
20+
21+
## Index
22+
1. [Installation](https://github.com/TrackingMores/trackingmore-sdk-python#installation)
23+
2. [Testing](https://github.com/TrackingMores/trackingmore-sdk-python#testing)
24+
3. [Error Handling](https://github.com/TrackingMores/trackingmore-sdk-python#error-handling)
25+
4. SDK
26+
1. [Couriers](https://github.com/TrackingMores/trackingmore-sdk-python#couriers)
27+
2. [Trackings](https://github.com/TrackingMores/trackingmore-sdk-python#trackings)
28+
3. [Air Waybill](https://github.com/TrackingMores/trackingmore-sdk-python#air-waybill)
29+
30+
31+
## Installation
32+
33+
```
34+
$ pip install trackingmore
35+
```
36+
37+
## Via source code
38+
39+
Download the code archive, without unzip it, go to the
40+
source root directory, then run:
41+
42+
```
43+
$ pip install trackingmore-sdk-python.zip
44+
```
45+
46+
## Quick Start
47+
48+
```python
49+
import trackingmore
50+
51+
trackingmore.api_key = 'you api key'
52+
53+
couriers = trackingmore.courier.get_all_couriers()
54+
```
55+
56+
## Testing
57+
```
58+
pytest
59+
```
60+
61+
## Error handling
62+
63+
**Throw** by the new SDK client
64+
65+
```python
66+
import trackingmore
67+
68+
trackingmore.api_key = ''
69+
70+
try:
71+
couriers = trackingmore.courier.get_all_couriers()
72+
print(couriers)
73+
except trackingmore.exception.TrackingMoreException as ce:
74+
print(ce)
75+
76+
# API Key is missing
77+
```
78+
79+
**Throw** by the parameter validation in function
80+
81+
```python
82+
import trackingmore
83+
84+
trackingmore.api_key = 'you api key'
85+
86+
try:
87+
params = {'tracking_number': ''}
88+
couriers = trackingmore.courier.detect(params)
89+
print(couriers)
90+
except trackingmore.exception.TrackingMoreException as ce:
91+
print(ce)
92+
93+
# Tracking number cannot be empty
94+
```
95+
## Examples
96+
97+
## Couriers
98+
##### Return a list of all supported couriers.
99+
https://api.trackingmore.com/v4/couriers/all
100+
```python
101+
try:
102+
result = trackingmore.courier.get_all_couriers()
103+
print(result)
104+
except trackingmore.exception.TrackingMoreException as ce:
105+
print(ce)
106+
```
107+
108+
##### Return a list of matched couriers based on submitted tracking number.
109+
https://api.trackingmore.com/v4/couriers/detect
110+
```python
111+
params = {'tracking_number': '92612903029511573030094547'}
112+
try:
113+
result = trackingmore.courier.detect(params)
114+
print(result)
115+
except trackingmore.exception.TrackingMoreException as ce:
116+
print(ce)
117+
```
118+
119+
## Trackings
120+
##### Create a tracking.
121+
https://api.trackingmore.com/v4/trackings/create
122+
```python
123+
try:
124+
params = {'tracking_number': '92612903029511573030094547','courier_code':'usps'}
125+
result = trackingmore.tracking.create_tracking(params)
126+
print(result)
127+
except trackingmore.exception.TrackingMoreException as ce:
128+
print(ce)
129+
```
130+
131+
##### Get tracking results of multiple trackings.
132+
https://api.trackingmore.com/v4/trackings/get
133+
```python
134+
try:
135+
# Perform queries based on various conditions
136+
# params = {'tracking_numbers': '92612903029511573030094547', 'courier_code': 'usps'}
137+
# params = {'tracking_numbers': '92612903029511573030094547,92612903029511573030094548', 'courier_code': 'usps'}
138+
params = {'created_date_min': '2023-08-23T14:00:00+08:00', 'created_date_max': '2023-08-23T15:04:00+08:00'}
139+
result = trackingmore.tracking.get_tracking_results(params)
140+
print(result)
141+
except trackingmore.exception.TrackingMoreException as ce:
142+
print(ce)
143+
```
144+
145+
##### Create multiple trackings (Max. 40 tracking numbers create in one call).
146+
https://api.trackingmore.com/v4/trackings/batch
147+
```python
148+
try:
149+
params = [{'tracking_number': '92612903029511573030094593', 'courier_code': 'usps'},
150+
{'tracking_number': '92612903029511573030094594', 'courier_code': 'usps'}]
151+
result = trackingmore.tracking.batch_create_trackings(params)
152+
print(result)
153+
except trackingmore.exception.TrackingMoreException as ce:
154+
print(ce)
155+
```
156+
157+
##### Update a tracking by ID.
158+
https://api.trackingmore.com/v4/trackings/update/{id}
159+
```python
160+
params = {'customer_name': 'New name', 'note': 'New tests order note'}
161+
id_string = "9a2f732e29b5ed2071d4cf6b5f4a3d19"
162+
try:
163+
result = trackingmore.tracking.update_tracking_by_id(id_string, params)
164+
print(result)
165+
except trackingmore.exception.TrackingMoreException as ce:
166+
print(ce)
167+
```
168+
169+
##### Delete a tracking by ID.
170+
https://api.trackingmore.com/v4/trackings/delete/{id}
171+
```python
172+
id_string = "9a2f7d1e8b912b729388c5835c188c28"
173+
try:
174+
result = trackingmore.tracking.batch_create_trackings(params)
175+
print(result)
176+
except trackingmore.exception.TrackingMoreException as ce:
177+
print(ce)
178+
```
179+
180+
##### Retrack expired tracking by ID.
181+
https://api.trackingmore.com/v4/trackings/retrack/{id}
182+
```python
183+
id_string = "9a2f7d1e8b912b729388c5835c188c28"
184+
try:
185+
result = trackingmore.tracking.retrack_tracking_by_id(id_string)
186+
print(result)
187+
except trackingmore.exception.TrackingMoreException as ce:
188+
print(ce)
189+
```
190+
## Air Waybill
191+
##### Create an air waybill.
192+
https://api.trackingmore.com/v4/awb
193+
```python
194+
params = {'awb_number': '235-69030430'}
195+
try:
196+
result = trackingmore.air_waybill.create_an_air_waybill(params)
197+
print(result)
198+
except trackingmore.exception.TrackingMoreException as ce:
199+
print(ce)
200+
```
201+
202+
## Response Code
203+
204+
Trackingmore uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g. a required parameter was missing, a charge failed, etc.), and codes in the 5xx range indicate an TrackingMore's server error.
205+
206+
207+
Http CODE|META CODE|TYPE | MESSAGE
208+
----|-----|--------------|-------------------------------
209+
200 |200 | <code>Success</code> | Request response is successful
210+
400 |400 | <code>BadRequest</code> | Request type error. Please check the API documentation for the request type of this API.
211+
400 |4101 | <code>BadRequest</code> | Tracking No. already exists.
212+
400 |4102 | <code>BadRequest</code> | Tracking No. no exists. Please use 「Create a tracking」 API first to create shipment.
213+
400 |4103 | <code>BadRequest</code> | You have exceeded the shipment quantity of API call. The maximum quantity is 40 shipments per call.
214+
400 |4110 | <code>BadRequest</code> | The value of tracking_number is invalid.
215+
400 |4111 | <code>BadRequest</code> | Tracking_number is required.
216+
400 |4112 | <code>BadRequest</code> | Invalid Tracking ID.
217+
400 |4113 | <code>BadRequest</code> | Retrack is not allowed. You can only retrack an expired tracking.
218+
400 |4120 | <code>BadRequest</code> | The value of courier_code is invalid.
219+
400 |4121 | <code>BadRequest</code> | Cannot detect courier.
220+
400 |4122 | <code>BadRequest</code> | Missing or invalid value of the special required fields for this courier.
221+
400 |4130 | <code>BadRequest</code> | The format of Field name is invalid.
222+
400 |4160 | <code>BadRequest</code> | The awb_number is required or invaild format.
223+
400 |4161 | <code>BadRequest</code> | The awb airline does not support yet.
224+
400 |4190 | <code>BadRequest</code> | You are reaching the maximum quota limitation, please upgrade your current plan.
225+
401 |401 | <code>Unauthorized</code> | Authentication failed or has no permission. Please check and ensure your API Key is correct.
226+
403 |403 | <code>Forbidden</code> | Access prohibited. The request has been refused or access is not allowed.
227+
404 |404 | <code>NotFound</code> | Page does not exist. Please check and ensure your link is correct.
228+
429 |429 | <code>TooManyRequests</code>| Exceeded API request limits, please try again later. Please check the API documentation for the limit of this API.
229+
500 |511 | <code>ServerError</code> | Server error. Please contact us: service@trackingmore.org.
230+
500 |512 | <code>ServerError</code> | Server error. Please contact us: service@trackingmore.org.
231+
500 |513 | <code>ServerError</code> | Server error. Please contact us: service@trackingmore.org.

0 commit comments

Comments
 (0)