Skip to content

Commit b8a15f3

Browse files
authored
Merge pull request #26 from 1415003719/2025-04
support 2025-04 version
2 parents 6319e76 + 7127e0e commit b8a15f3

File tree

177 files changed

+5804
-5599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+5804
-5599
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Jenkinsfile

LICENSE.txt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1+
MIT License
2+
13
Copyright (c) 2025 AfterShip
24

3-
Permission is hereby granted, free of charge, to any person
4-
obtaining a copy of this software and associated documentation
5-
files (the "Software"), to deal in the Software without
6-
restriction, including without limitation the rights to use,
7-
copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
copies of the Software, and to permit persons to whom the
9-
Software is furnished to do so, subject to the following
10-
conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
1111

12-
The above copyright notice and this permission notice shall be
13-
included in all copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1414

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22-
OTHER DEALINGS IN THE SOFTWARE.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 125 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ If you need support using AfterShip products, please contact [email protected]
2222
- [Endpoints](#endpoints)
2323
- [/trackings](#trackings)
2424
- [/couriers](#couriers)
25+
- [/courier-connections](#courier-connections)
2526
- [/estimated-delivery-date](#estimated-delivery-date)
2627
- [Help](#help)
2728
- [License](#license)
2829

30+
2931
## Before you begin
3032

3133
Before you begin to integrate:
@@ -38,19 +40,20 @@ Before you begin to integrate:
3840

3941
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.
4042

41-
| SDK Version | Supported API Version | Branch |
42-
| ----------- | --------------------- | ------------------------------------------------------------- |
43-
| 12.x.x | 2025-01 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2025-01 |
44-
| 11.x.x | 2024-10 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2024-10 |
45-
| 10.x.x | 2024-07 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2024-07 |
46-
| 9.x.x | 2024-04 | https://github.com/AfterShip/tracking-sdk-nodejs/tree/2024-04 |
47-
| 8.x.x | 2023-10 | https://github.com/AfterShip/aftership-sdk-nodejs |
48-
| <=7.x.x | Legacy API | https://github.com/AfterShip/aftership-sdk-nodejs |
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+
4953

5054
## Quick Start
5155

5256
### Installation
53-
5457
```bash
5558
npm install --save @aftership/tracking-sdk
5659
```
@@ -61,7 +64,7 @@ Create AfterShip instance with options
6164

6265
| Name | Type | Required | Description |
6366
| ---------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
64-
| api_key | string || Your AfterShip API key |
67+
| api_key | string | | Your AfterShip API key |
6568
| auth_type | enum | | Default value: `AuthType.API_KEY` <br > AES authentication: `AuthType.AES` <br > RSA authentication: `AuthType.RSA` |
6669
| api_secret | string | | Required if the authentication type is `AuthType.AES` or `AuthType.RSA` |
6770
| domain | string | | AfterShip API domain. Default value: https://api.aftership.com |
@@ -74,43 +77,44 @@ Create AfterShip instance with options
7477

7578
```javascript
7679
// Step 1: Require the AfterShip client
77-
import { AfterShip } from "@aftership/tracking-sdk";
80+
import {AfterShip} from '@aftership/tracking-sdk';
7881
// or
7982
// const {AfterShip} = require('@aftership/tracking-sdk');
8083

84+
8185
// Step 2: Initialize the client object
82-
const aftership = new AfterShip({ api_key: "YOUR_API_KEY" });
86+
const aftership = new AfterShip({api_key: 'YOUR_API_KEY'});
8387

8488
// Step 3: Create the request object
8589
const createTrackingRequestBody = {
86-
tracking_number: "<tracking_number>",
87-
slug: "<slug>",
90+
tracking_number: '<tracking_number>',
91+
slug: '<slug>'
8892
};
8993

9094
// Step 4: Make the request
91-
aftership.tracking
92-
.createTracking(createTrackingRequestBody)
93-
.then((tracking) => console.log(tracking))
94-
.catch((error) => console.log(error));
95+
aftership.tracking.createTracking(createTrackingRequestBody)
96+
.then(tracking => console.log(tracking))
97+
.catch(error => console.log(error));
9598
```
9699

97100
## Rate Limiter
98101

99-
See the [Rate Limit](https://www.aftership.com/docs/tracking/2024-10/quickstart/rate-limit) to understand the AfterShip rate limit policy.
102+
See the [Rate Limit](https://www.aftership.com/docs/tracking/2025-04/quickstart/rate-limit) to understand the AfterShip rate limit policy.
100103

101104
## Error Handling
102105

103106
The SDK will return an error object when there is any error during the request, with the following specification:
104107

105-
| Name | Type | Description |
106-
| ---------------- | ------ | ------------------------------ |
107-
| message | string | Detail message of the error |
108-
| code | enum | Error code enum for API Error. |
109-
| meta_code | number | API response meta code. |
110-
| status_code | number | HTTP status code. |
111-
| 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. |
112115
| response_headers | object | API response header. |
113116

117+
114118
### Error List
115119

116120
| code | meta_code | status_code | message |
@@ -144,8 +148,9 @@ The AfterShip instance has the following properties which are exactly the same a
144148

145149
- courier - Get a list of our supported couriers.
146150
- tracking - Create trackings, update trackings, and get tracking results.
151+
- courier-connection - Create courier connections, update courier connections, and get courier connections results.
147152
- estimated-delivery-date - Get estimated delivery date for your order.
148-
153+
149154
### /trackings
150155

151156
**POST** /trackings
@@ -164,92 +169,128 @@ const payload = {
164169
};
165170

166171
aftership.tracking
167-
.createTracking(payload)
168-
.then((result) => console.log(result))
169-
.catch((e) => console.log(e));
172+
.createTracking(payload)
173+
.then((result) => console.log(result))
174+
.catch((e) => console.log(e));
170175
```
171176

172177
**DELETE** /trackings/:id
173178

174179
```javascript
175180
aftership.tracking
176-
.deleteTrackingById("<tracking_id>")
177-
.then((result) => console.log(result))
178-
.catch((e) => console.log(e));
181+
.deleteTrackingById('<tracking_id>')
182+
.then((result) => console.log(result))
183+
.catch((e) => console.log(e));
179184
```
180185

181186
**GET** /trackings
182187

183188
```javascript
184189
aftership.tracking
185-
.getTrackings({ limit: 10, fields: "slug,tracking_number" })
186-
.then((result) => console.log(result))
187-
.catch((e) => console.log(e));
190+
.getTrackings({ limit: 10, fields: 'slug,tracking_number' })
191+
.then((result) => console.log(result))
192+
.catch((e) => console.log(e));
188193
```
189194

190195
**GET** /trackings/:id
191196

192197
```javascript
193198
aftership.tracking
194-
.getTrackingById("<tracking_id>")
195-
.then((result) => console.log(result))
196-
.catch((e) => console.log(e));
199+
.getTrackingById('<tracking_id>')
200+
.then((result) => console.log(result))
201+
.catch((e) => console.log(e));
197202
```
198203

199204
**PUT** /trackings/:id
200205

201206
```javascript
202207
aftership.tracking
203-
.updateTrackingById("<tracking_id>", { title: "New Title123" })
204-
.then((result) => console.log(result))
205-
.catch((e) => console.log(e));
208+
.updateTrackingById('<tracking_id>',{title: 'New Title123'})
209+
.then((result) => console.log(result))
210+
.catch((e) => console.log(e));
206211
```
207212

208213
**POST** /trackings/:id/retrack
209214

210215
```javascript
211216
aftership.tracking
212-
.retrackTrackingById("<tracking_id>")
213-
.then((result) => console.log(result))
214-
.catch((e) => console.log(e));
217+
.retrackTrackingById('<tracking_id>')
218+
.then((result) => console.log(result))
219+
.catch((e) => console.log(e));
215220
```
216221

217222
**POST** /trackings/:id/mark-as-completed
218223

219224
```javascript
220225
aftership.tracking
221-
.markTrackingCompletedById("<tracking_id>", { reason: "DELIVERED" })
222-
.then((result) => console.log(result))
223-
.catch((e) => console.log(e));
226+
.markTrackingCompletedById('<tracking_id>', { reason: 'DELIVERED' })
227+
.then((result) => console.log(result))
228+
.catch((e) => console.log(e));
224229
```
225230

226231
### /couriers
227-
228232
**GET** /couriers
229233

230234
```javascript
231235
aftership.courier
232-
.getUserCouriers()
233-
.then((result) => console.log(result))
234-
.catch((e) => console.log(e));
236+
.GetCouriers()
237+
.then(result => console.log(result))
238+
.catch(e => console.log(e));
235239
```
236240

237-
**GET** /couriers/all
241+
**POST** /couriers/detect
242+
243+
```js
244+
aftership.courier
245+
.detectCourier({ tracking_number: '<tracking_number>' })
246+
.then(result => console.log(result))
247+
.catch(e => console.log(e));
248+
```
249+
250+
### /courier-connections
251+
**GET** /courier-connections
238252

239253
```javascript
240254
aftership.courier
241-
.getAllCouriers()
242-
.then((result) => console.log(result))
243-
.catch((e) => console.log(e));
255+
.getCourierConnections()
256+
.then(result => console.log(result))
257+
.catch(e => console.log(e));
244258
```
245259

246-
**POST** /couriers/detect
260+
**POST** /courier-connections
247261

248262
```js
249263
aftership.courier
250-
.detectCourier({ tracking_number: "<tracking_number>" })
251-
.then((result) => console.log(result))
252-
.catch((e) => console.log(e));
264+
.postCourierConnections({courier_slug: "dhl-api", credentials: {"api_key": "<api_key>"}})
265+
.then(result => console.log(result))
266+
.catch(e => console.log(e));
267+
```
268+
269+
**GET** /courier-connections/:id
270+
271+
```js
272+
aftership.courier
273+
.getCourierConnectionsById("<courier_connection_id>")
274+
.then(result => console.log(result))
275+
.catch(e => console.log(e));
276+
```
277+
278+
**PATCH** /courier-connections/:id
279+
280+
```js
281+
aftership.courier
282+
.putCourierConnectionsById("<courier_connection_id>", {credentials: {"api_key": "<api_key>"}})
283+
.then(result => console.log(result))
284+
.catch(e => console.log(e));
285+
```
286+
287+
**DELETE** /courier-connections/:id
288+
289+
```js
290+
aftership.courier
291+
.deleteCourierConnectionsById("<courier_connection_id>")
292+
.then(result => console.log(result))
293+
.catch(e => console.log(e));
253294
```
254295

255296
### /estimated-delivery-date
@@ -258,20 +299,33 @@ aftership.courier
258299

259300
```javascript
260301
const payload = {
261-
estimated_delivery_dates: [
262-
{
263-
slug: "<slug>",
264-
origin_address: { country: "<country>" },
265-
destination_address: { country: "<country>" },
266-
},
267-
],
302+
estimated_delivery_dates: [{
303+
slug: '<slug>',
304+
origin_address: { country: '<country>' },
305+
destination_address: { country: '<country>' },
306+
}]
307+
};
308+
aftership.estimatedDeliveryDate
309+
.predictBatch(payload)
310+
.then(result => console.log(result))
311+
.catch(e => console.log(e));
312+
```
313+
314+
**POST** /estimated-delivery-date/predict
315+
316+
```javascript
317+
const payload = {
318+
slug: '<slug>',
319+
origin_address: { country: '<country>' },
320+
destination_address: { country: '<country>' },
268321
};
269322
aftership.estimatedDeliveryDate
270-
.predictBatch(payload)
271-
.then((result) => console.log(result))
272-
.catch((e) => console.log(e));
323+
.predict(payload)
324+
.then(result => console.log(result))
325+
.catch(e => console.log(e));
273326
```
274327

328+
275329
## Help
276330

277331
If you get stuck, we're here to help:
@@ -280,7 +334,6 @@ If you get stuck, we're here to help:
280334
- Contact AfterShip official support via [email protected]
281335

282336
## License
283-
284337
Copyright (c) 2025 AfterShip
285338

286-
Licensed under the MIT license.
339+
Licensed under the MIT license.

0 commit comments

Comments
 (0)