@@ -27,7 +27,6 @@ If you need support using AfterShip products, please contact
[email protected]
27
27
- [ Help] ( #help )
28
28
- [ License] ( #license )
29
29
30
-
31
30
## Before you begin
32
31
33
32
Before you begin to integrate:
@@ -40,20 +39,21 @@ Before you begin to integrate:
40
39
41
40
Each SDK version is designed to work with a specific API version. Please refer to the table below to identify the supported API versions for each SDK version, ensuring you select the appropriate SDK version for the API version you intend to use.
42
41
43
- | SDK Version | Supported API Version | Branch |
44
- | --- | --- | --- |
45
- | 13 .x.x | 2025-04 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2025-04 |
46
- | 12 .x.x | 2025-01 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2025-01 |
47
- | 11 .x.x | 2024-10 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2024-10 |
48
- | 10 .x.x | 2024-07 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2024-07 |
49
- | 9 .x.x | 2024-04 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2024-04 |
50
- | 8 .x.x | 2023-10 | https://github.com/AfterShip/aftership -sdk-nodejs |
51
- | <=7 .x.x | Legacy API | https://github.com/AfterShip/aftership-sdk-nodejs |
52
-
42
+ | SDK Version | Supported API Version | Branch |
43
+ | ----------- | --------------------- | ---------------------------------------------------------- --- |
44
+ | 14 .x.x | 2025-07 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2025-07 |
45
+ | 13 .x.x | 2025-04 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2025-04 |
46
+ | 12 .x.x | 2025-01 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2025-01 |
47
+ | 11 .x.x | 2024-10 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2024-10 |
48
+ | 10 .x.x | 2024-07 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2024-07 |
49
+ | 9 .x.x | 2024-04 | https://github.com/AfterShip/tracking -sdk-nodejs/tree/2024-04 |
50
+ | 8 .x.x | 2023-10 | https://github.com/AfterShip/aftership-sdk-nodejs |
51
+ | <=7.x.x | Legacy API | https://github.com/AfterShip/aftership-sdk-nodejs |
53
52
54
53
## Quick Start
55
54
56
55
### Installation
56
+
57
57
``` bash
58
58
npm install --save @aftership/tracking-sdk
59
59
```
@@ -64,7 +64,7 @@ Create AfterShip instance with options
64
64
65
65
| Name | Type | Required | Description |
66
66
| ---------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
67
- | api_key | string | ✔ | Your AfterShip API key |
67
+ | api_key | string | ✔ | Your AfterShip API key |
68
68
| auth_type | enum | | Default value: ` AuthType.API_KEY ` <br > AES authentication: ` AuthType.AES ` <br > RSA authentication: ` AuthType.RSA ` |
69
69
| api_secret | string | | Required if the authentication type is ` AuthType.AES ` or ` AuthType.RSA ` |
70
70
| domain | string | | AfterShip API domain. Default value: https://api.aftership.com |
@@ -77,44 +77,43 @@ Create AfterShip instance with options
77
77
78
78
``` javascript
79
79
// Step 1: Require the AfterShip client
80
- import {AfterShip } from ' @aftership/tracking-sdk' ;
80
+ import { AfterShip } from " @aftership/tracking-sdk" ;
81
81
// or
82
82
// const {AfterShip} = require('@aftership/tracking-sdk');
83
83
84
-
85
84
// Step 2: Initialize the client object
86
- const aftership = new AfterShip ({api_key: ' YOUR_API_KEY' });
85
+ const aftership = new AfterShip ({ api_key: " YOUR_API_KEY" });
87
86
88
87
// Step 3: Create the request object
89
88
const createTrackingRequestBody = {
90
- tracking_number: ' <tracking_number>' ,
91
- slug: ' <slug>'
89
+ tracking_number: " <tracking_number>" ,
90
+ slug: " <slug>" ,
92
91
};
93
92
94
93
// Step 4: Make the request
95
- aftership .tracking .createTracking (createTrackingRequestBody)
96
- .then (tracking => console .log (tracking))
97
- .catch (error => console .log (error));
94
+ aftership .tracking
95
+ .createTracking (createTrackingRequestBody)
96
+ .then ((tracking ) => console .log (tracking))
97
+ .catch ((error ) => console .log (error));
98
98
```
99
99
100
100
## Rate Limiter
101
101
102
- See the [ Rate Limit] ( https://www.aftership.com/docs/tracking/2025-04 /quickstart/rate-limit ) to understand the AfterShip rate limit policy.
102
+ See the [ Rate Limit] ( https://www.aftership.com/docs/tracking/2025-07 /quickstart/rate-limit ) to understand the AfterShip rate limit policy.
103
103
104
104
## Error Handling
105
105
106
106
The SDK will return an error object when there is any error during the request, with the following specification:
107
107
108
- | Name | Type | Description |
109
- | --------------- | ------ | ------------------------------ |
110
- | message | string | Detail message of the error |
111
- | code | enum | Error code enum for API Error. |
112
- | meta_code | number | API response meta code. |
113
- | status_code | number | HTTP status code. |
114
- | response_body | string | API response body. |
108
+ | Name | Type | Description |
109
+ | ---------------- | ------ | ------------------------------ |
110
+ | message | string | Detail message of the error |
111
+ | code | enum | Error code enum for API Error. |
112
+ | meta_code | number | API response meta code. |
113
+ | status_code | number | HTTP status code. |
114
+ | response_body | string | API response body. |
115
115
| response_headers | object | API response header. |
116
116
117
-
118
117
### Error List
119
118
120
119
| code | meta_code | status_code | message |
@@ -150,7 +149,7 @@ The AfterShip instance has the following properties which are exactly the same a
150
149
- tracking - Create trackings, update trackings, and get tracking results.
151
150
- courier-connection - Create courier connections, update courier connections, and get courier connections results.
152
151
- estimated-delivery-date - Get estimated delivery date for your order.
153
-
152
+
154
153
### /trackings
155
154
156
155
** POST** /trackings
@@ -169,128 +168,135 @@ const payload = {
169
168
};
170
169
171
170
aftership .tracking
172
- .createTracking (payload)
173
- .then ((result ) => console .log (result))
174
- .catch ((e ) => console .log (e));
171
+ .createTracking (payload)
172
+ .then ((result ) => console .log (result))
173
+ .catch ((e ) => console .log (e));
175
174
```
176
175
177
176
** DELETE** /trackings/: id
178
177
179
178
``` javascript
180
179
aftership .tracking
181
- .deleteTrackingById (' <tracking_id>' )
182
- .then ((result ) => console .log (result))
183
- .catch ((e ) => console .log (e));
180
+ .deleteTrackingById (" <tracking_id>" )
181
+ .then ((result ) => console .log (result))
182
+ .catch ((e ) => console .log (e));
184
183
```
185
184
186
185
** GET** /trackings
187
186
188
187
``` javascript
189
188
aftership .tracking
190
- .getTrackings ({ limit: 10 , fields: ' slug,tracking_number' })
191
- .then ((result ) => console .log (result))
192
- .catch ((e ) => console .log (e));
189
+ .getTrackings ({ limit: 10 , fields: " slug,tracking_number" })
190
+ .then ((result ) => console .log (result))
191
+ .catch ((e ) => console .log (e));
193
192
```
194
193
195
194
** GET** /trackings/: id
196
195
197
196
``` javascript
198
197
aftership .tracking
199
- .getTrackingById (' <tracking_id>' )
200
- .then ((result ) => console .log (result))
201
- .catch ((e ) => console .log (e));
198
+ .getTrackingById (" <tracking_id>" )
199
+ .then ((result ) => console .log (result))
200
+ .catch ((e ) => console .log (e));
202
201
```
203
202
204
203
** PUT** /trackings/: id
205
204
206
205
``` javascript
207
206
aftership .tracking
208
- .updateTrackingById (' <tracking_id>' ,{ title: ' New Title123' })
209
- .then ((result ) => console .log (result))
210
- .catch ((e ) => console .log (e));
207
+ .updateTrackingById (" <tracking_id>" , { title: " New Title123" })
208
+ .then ((result ) => console .log (result))
209
+ .catch ((e ) => console .log (e));
211
210
```
212
211
213
212
** POST** /trackings/: id /retrack
214
213
215
214
``` javascript
216
215
aftership .tracking
217
- .retrackTrackingById (' <tracking_id>' )
218
- .then ((result ) => console .log (result))
219
- .catch ((e ) => console .log (e));
216
+ .retrackTrackingById (" <tracking_id>" )
217
+ .then ((result ) => console .log (result))
218
+ .catch ((e ) => console .log (e));
220
219
```
221
220
222
221
** POST** /trackings/: id /mark-as-completed
223
222
224
223
``` javascript
225
224
aftership .tracking
226
- .markTrackingCompletedById (' <tracking_id>' , { reason: ' DELIVERED' })
227
- .then ((result ) => console .log (result))
228
- .catch ((e ) => console .log (e));
225
+ .markTrackingCompletedById (" <tracking_id>" , { reason: " DELIVERED" })
226
+ .then ((result ) => console .log (result))
227
+ .catch ((e ) => console .log (e));
229
228
```
230
229
231
230
### /couriers
231
+
232
232
** GET** /couriers
233
233
234
234
``` javascript
235
235
aftership .courier
236
- .GetCouriers ()
237
- .then (result => console .log (result))
238
- .catch (e => console .log (e));
236
+ .GetCouriers ()
237
+ .then (( result ) => console .log (result))
238
+ .catch (( e ) => console .log (e));
239
239
```
240
240
241
241
** POST** /couriers/detect
242
242
243
243
``` js
244
244
aftership .courier
245
- .detectCourier ({ tracking_number: ' <tracking_number>' })
246
- .then (result => console .log (result))
247
- .catch (e => console .log (e));
245
+ .detectCourier ({ tracking_number: " <tracking_number>" })
246
+ .then (( result ) => console .log (result))
247
+ .catch (( e ) => console .log (e));
248
248
```
249
249
250
250
### /courier-connections
251
+
251
252
** GET** /courier-connections
252
253
253
254
``` javascript
254
255
aftership .courier
255
- .getCourierConnections ()
256
- .then (result => console .log (result))
257
- .catch (e => console .log (e));
256
+ .getCourierConnections ()
257
+ .then (( result ) => console .log (result))
258
+ .catch (( e ) => console .log (e));
258
259
```
259
260
260
261
** POST** /courier-connections
261
262
262
263
``` js
263
264
aftership .courier
264
- .postCourierConnections ({courier_slug: " dhl-api" , credentials: {" api_key" : " <api_key>" }})
265
- .then (result => console .log (result))
266
- .catch (e => console .log (e));
265
+ .postCourierConnections ({
266
+ courier_slug: " dhl-api" ,
267
+ credentials: { api_key: " <api_key>" },
268
+ })
269
+ .then ((result ) => console .log (result))
270
+ .catch ((e ) => console .log (e));
267
271
```
268
272
269
273
** GET** /courier-connections/: id
270
274
271
275
``` js
272
276
aftership .courier
273
- .getCourierConnectionsById (" <courier_connection_id>" )
274
- .then (result => console .log (result))
275
- .catch (e => console .log (e));
277
+ .getCourierConnectionsById (" <courier_connection_id>" )
278
+ .then (( result ) => console .log (result))
279
+ .catch (( e ) => console .log (e));
276
280
```
277
281
278
282
** PATCH** /courier-connections/: id
279
283
280
284
``` js
281
285
aftership .courier
282
- .putCourierConnectionsById (" <courier_connection_id>" , {credentials: {" api_key" : " <api_key>" }})
283
- .then (result => console .log (result))
284
- .catch (e => console .log (e));
286
+ .putCourierConnectionsById (" <courier_connection_id>" , {
287
+ credentials: { api_key: " <api_key>" },
288
+ })
289
+ .then ((result ) => console .log (result))
290
+ .catch ((e ) => console .log (e));
285
291
```
286
292
287
293
** DELETE** /courier-connections/: id
288
294
289
295
``` js
290
296
aftership .courier
291
- .deleteCourierConnectionsById (" <courier_connection_id>" )
292
- .then (result => console .log (result))
293
- .catch (e => console .log (e));
297
+ .deleteCourierConnectionsById (" <courier_connection_id>" )
298
+ .then (( result ) => console .log (result))
299
+ .catch (( e ) => console .log (e));
294
300
```
295
301
296
302
### /estimated-delivery-date
@@ -299,33 +305,34 @@ aftership.courier
299
305
300
306
``` javascript
301
307
const payload = {
302
- estimated_delivery_dates: [{
303
- slug: ' <slug>' ,
304
- origin_address: { country: ' <country>' },
305
- destination_address: { country: ' <country>' },
306
- }]
308
+ estimated_delivery_dates: [
309
+ {
310
+ slug: " <slug>" ,
311
+ origin_address: { country: " <country>" },
312
+ destination_address: { country: " <country>" },
313
+ },
314
+ ],
307
315
};
308
316
aftership .estimatedDeliveryDate
309
- .predictBatch (payload)
310
- .then (result => console .log (result))
311
- .catch (e => console .log (e));
317
+ .predictBatch (payload)
318
+ .then (( result ) => console .log (result))
319
+ .catch (( e ) => console .log (e));
312
320
```
313
321
314
322
** POST** /estimated-delivery-date/predict
315
323
316
324
``` javascript
317
325
const payload = {
318
- slug: ' <slug>' ,
319
- origin_address: { country: ' <country>' },
320
- destination_address: { country: ' <country>' },
326
+ slug: " <slug>" ,
327
+ origin_address: { country: " <country>" },
328
+ destination_address: { country: " <country>" },
321
329
};
322
330
aftership .estimatedDeliveryDate
323
- .predict (payload)
324
- .then (result => console .log (result))
325
- .catch (e => console .log (e));
331
+ .predict (payload)
332
+ .then (( result ) => console .log (result))
333
+ .catch (( e ) => console .log (e));
326
334
```
327
335
328
-
329
336
## Help
330
337
331
338
If you get stuck, we're here to help:
@@ -334,6 +341,7 @@ If you get stuck, we're here to help:
334
341
- Contact AfterShip official support via
[email protected]
335
342
336
343
## License
344
+
337
345
Copyright (c) 2025 AfterShip
338
346
339
- Licensed under the MIT license.
347
+ Licensed under the MIT license.
0 commit comments