|
1 | 1 | Get Rates With Shipment Details |
2 | 2 | ====================================== |
3 | | -Given some shipment details and rate options, this method returns a list of rate quotes. |
| 3 | +Given some shipment details and rate options, this method returns a list of rate quotes. Please see [our docs](https://www.shipengine.com/docs/rates/) to learn more about calculating rates. |
4 | 4 |
|
5 | | -> Coming Soon |
| 5 | +Input Parameters |
| 6 | +------------------------------------- |
| 7 | + |
| 8 | +The `getRatesWithShipmentDetails` method accepts shipment related params. If you are using TypeScript, you can import the [`GetRatesWithShipmentDetailsTypes.Param`](https://github.com/ShipEngine/shipengine-js/blob/main/src/get-rates-with-shipment-details/types/public-params.ts) |
| 9 | +type into your project to take advantage of your |
| 10 | +IDE's code completion functionality. |
| 11 | + |
| 12 | +Output |
| 13 | +-------------------------------- |
| 14 | +The `getRatesWithShipmentDetails` method returns the rates that were calculated for the given shipment params. |
| 15 | +If you are using TypeScript, you can import the [`GetRatesWithShipmentDetailsTypes.Result`](https://github.com/ShipEngine/shipengine-js/blob/main/src/get-rates-with-shipment-details/types/public-result.ts) |
| 16 | +type into your project to take advantage of your IDE's code completion functionality. |
| 17 | + |
| 18 | +Example |
| 19 | +============================== |
| 20 | +```javascript |
| 21 | +const ShipEngine = require("shipengine"); |
| 22 | +const shipengine = new ShipEngine("api_key"); |
| 23 | + |
| 24 | +async function getRatesWithShipmentDetails() { |
| 25 | + const params = { |
| 26 | + rateOptions: { |
| 27 | + carrierIds: ["se-423888"] |
| 28 | + }, |
| 29 | + shipment: { |
| 30 | + validateAddress: "no_validation", |
| 31 | + shipTo: { |
| 32 | + name: "Amanda Miller", |
| 33 | + phone: "555-555-5555", |
| 34 | + addressLine1: "525 S Winchester Blvd", |
| 35 | + cityLocality: "San Jose", |
| 36 | + stateProvince: "CA", |
| 37 | + postalCode: "95128", |
| 38 | + countryCode: "US", |
| 39 | + addressResidentialIndicator: "yes", |
| 40 | + }, |
| 41 | + shipFrom: { |
| 42 | + companyName: "Example Corp.", |
| 43 | + name: "John Doe", |
| 44 | + phone: "111-111-1111", |
| 45 | + addressLine1: "4009 Marathon Blvd", |
| 46 | + addressLine2: "Suite 300", |
| 47 | + cityLocality: "Austin", |
| 48 | + stateProvince: "TX", |
| 49 | + postalCode: "78756", |
| 50 | + countryCode: "US", |
| 51 | + addressResidentialIndicator: "no", |
| 52 | + }, |
| 53 | + packages: [ |
| 54 | + { |
| 55 | + weight: { |
| 56 | + value: 1.0, |
| 57 | + unit: "ounce", |
| 58 | + }, |
| 59 | + }, |
| 60 | + ], |
| 61 | + }, |
| 62 | + }; |
| 63 | + |
| 64 | + try { |
| 65 | + const result = await shipengine.getRatesWithShipmentDetails(params); |
| 66 | + |
| 67 | + console.log("The rates that were created:"); |
| 68 | + console.log(result); |
| 69 | + } catch (e) { |
| 70 | + console.log("Error creating rates: ", e.message); |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +getRatesWithShipmentDetails(); |
| 75 | +``` |
| 76 | + |
| 77 | +Example Output |
| 78 | +----------------------------------------------------- |
| 79 | + |
| 80 | +### Successful Get Rates Result |
| 81 | +```javascript |
| 82 | +{ |
| 83 | + shipmentId: "se-144012114", |
| 84 | + carrierId: "se-423888", |
| 85 | + serviceCode: null, |
| 86 | + externalOrderId: null, |
| 87 | + items: [], |
| 88 | + taxIdentifiers: null, |
| 89 | + externalShipmentId: null, |
| 90 | + shipDate: "2021-08-03T00:00:00Z", |
| 91 | + createdAt: "2021-08-03T19:00:20.327Z", |
| 92 | + modifiedAt: "2021-08-03T19:00:20.327Z", |
| 93 | + shipmentStatus: "pending", |
| 94 | + shipTo: { |
| 95 | + name: "Amanda Miller", |
| 96 | + phone: "555-555-5555", |
| 97 | + companyName: null, |
| 98 | + addressLine1: "525 S Winchester Blvd", |
| 99 | + addressLine2: null, |
| 100 | + addressLine3: null, |
| 101 | + cityLocality: "San Jose", |
| 102 | + stateProvince: "CA", |
| 103 | + postalCode: "95128", |
| 104 | + countryCode: "US", |
| 105 | + addressResidentialIndicator: "yes", |
| 106 | + }, |
| 107 | + shipFrom: { |
| 108 | + name: "John Doe", |
| 109 | + phone: "111-111-1111", |
| 110 | + companyName: "Example Corp.", |
| 111 | + addressLine1: "4009 Marathon Blvd", |
| 112 | + addressLine2: "Suite 300", |
| 113 | + addressLine3: null, |
| 114 | + cityLocality: "Austin", |
| 115 | + stateProvince: "TX", |
| 116 | + postalCode: "78756", |
| 117 | + countryCode: "US", |
| 118 | + addressResidentialIndicator: "unknown", |
| 119 | + }, |
| 120 | + warehouseId: null, |
| 121 | + returnTo: { |
| 122 | + name: "John Doe", |
| 123 | + phone: "111-111-1111", |
| 124 | + companyName: "Example Corp.", |
| 125 | + addressLine1: "4009 Marathon Blvd", |
| 126 | + addressLine2: "Suite 300", |
| 127 | + addressLine3: null, |
| 128 | + cityLocality: "Austin", |
| 129 | + stateProvince: "TX", |
| 130 | + postalCode: "78756", |
| 131 | + countryCode: "US", |
| 132 | + addressResidentialIndicator: "unknown", |
| 133 | + }, |
| 134 | + confirmation: "none", |
| 135 | + customs: { |
| 136 | + contents: "merchandise", |
| 137 | + nonDelivery: "return_to_sender", |
| 138 | + customsItems: [], |
| 139 | + }, |
| 140 | + advancedOptions: { |
| 141 | + billToAccount: null, |
| 142 | + billToCountryCode: null, |
| 143 | + billToParty: null, |
| 144 | + billToPostalCode: null, |
| 145 | + containsAlcohol: null, |
| 146 | + deliveryDutyPaid: null, |
| 147 | + dryIce: null, |
| 148 | + dryIceWeight: null, |
| 149 | + nonMachinable: null, |
| 150 | + saturdayDelivery: null, |
| 151 | + useUPSGroundFreightPricing: null, |
| 152 | + freightClass: null, |
| 153 | + customField1: null, |
| 154 | + customField2: null, |
| 155 | + customField3: null, |
| 156 | + originType: null, |
| 157 | + shipperRelease: null, |
| 158 | + collectOnDelivery: null, |
| 159 | + }, |
| 160 | + originType: null, |
| 161 | + insuranceProvider: "none", |
| 162 | + tags: [], |
| 163 | + orderSourceCode: null, |
| 164 | + packages: [ |
| 165 | + { |
| 166 | + packageCode: "package", |
| 167 | + weight: { value: 1, unit: "ounce" }, |
| 168 | + dimensions: { unit: "inch", length: 0, width: 0, height: 0 }, |
| 169 | + insuredValue: { currency: "usd", amount: 0 }, |
| 170 | + trackingNumber: null, |
| 171 | + labelMessages: { reference1: null, reference2: null, reference3: null }, |
| 172 | + externalPackageId: null, |
| 173 | + }, |
| 174 | + ], |
| 175 | + totalWeight: { value: 1, unit: "ounce" }, |
| 176 | + rateResponse: { |
| 177 | + rates: [ |
| 178 | + { |
| 179 | + rateId: "se-795561307", |
| 180 | + rateType: "shipment", |
| 181 | + carrierId: "se-423888", |
| 182 | + shippingAmount: { currency: "usd", amount: 32.57 }, |
| 183 | + insuranceAmount: { currency: "usd", amount: 0 }, |
| 184 | + confirmationAmount: { currency: "usd", amount: 0 }, |
| 185 | + otherAmount: { currency: "usd", amount: 0 }, |
| 186 | + taxAmount: null, |
| 187 | + zone: null, |
| 188 | + packageType: null, |
| 189 | + deliveryDays: 3, |
| 190 | + guaranteedService: true, |
| 191 | + estimatedDeliveryDate: "2021-08-06T23:00:00Z", |
| 192 | + carrierDeliveryDays: "Friday 8/6 by 11:00 PM", |
| 193 | + shipDate: "2021-08-03T00:00:00Z", |
| 194 | + negotiatedRate: false, |
| 195 | + serviceType: "UPS 3 Day Select®", |
| 196 | + serviceCode: "ups_3_day_select", |
| 197 | + trackable: true, |
| 198 | + carrierCode: "ups", |
| 199 | + carrierNickname: "ShipEngine Test Account - UPS", |
| 200 | + carrierFriendlyName: "UPS", |
| 201 | + validationStatus: "valid", |
| 202 | + warningMessages: [], |
| 203 | + errorMessages: [], |
| 204 | + }, |
| 205 | + { |
| 206 | + rateId: "se-795561308", |
| 207 | + rateType: "shipment", |
| 208 | + carrierId: "se-423888", |
| 209 | + shippingAmount: { currency: "usd", amount: 129.13 }, |
| 210 | + insuranceAmount: { currency: "usd", amount: 0 }, |
| 211 | + confirmationAmount: { currency: "usd", amount: 0 }, |
| 212 | + otherAmount: { currency: "usd", amount: 0 }, |
| 213 | + taxAmount: null, |
| 214 | + zone: null, |
| 215 | + packageType: null, |
| 216 | + deliveryDays: 1, |
| 217 | + guaranteedService: true, |
| 218 | + estimatedDeliveryDate: "2021-08-04T08:00:00Z", |
| 219 | + carrierDeliveryDays: "Tomorrow by 08:00 AM", |
| 220 | + shipDate: "2021-08-03T00:00:00Z", |
| 221 | + negotiatedRate: false, |
| 222 | + serviceType: "UPS Next Day Air® Early", |
| 223 | + serviceCode: "ups_next_day_air_early_am", |
| 224 | + trackable: true, |
| 225 | + carrierCode: "ups", |
| 226 | + carrierNickname: "ShipEngine Test Account - UPS", |
| 227 | + carrierFriendlyName: "UPS", |
| 228 | + validationStatus: "valid", |
| 229 | + warningMessages: [], |
| 230 | + errorMessages: [], |
| 231 | + }, |
| 232 | + { |
| 233 | + rateId: "se-795561309", |
| 234 | + rateType: "shipment", |
| 235 | + carrierId: "se-423888", |
| 236 | + shippingAmount: { currency: "usd", amount: 16.58 }, |
| 237 | + insuranceAmount: { currency: "usd", amount: 0 }, |
| 238 | + confirmationAmount: { currency: "usd", amount: 0 }, |
| 239 | + otherAmount: { currency: "usd", amount: 0 }, |
| 240 | + taxAmount: null, |
| 241 | + zone: null, |
| 242 | + packageType: null, |
| 243 | + deliveryDays: 4, |
| 244 | + guaranteedService: true, |
| 245 | + estimatedDeliveryDate: "2021-08-09T23:00:00Z", |
| 246 | + carrierDeliveryDays: "Monday 8/9 by 11:00 PM", |
| 247 | + shipDate: "2021-08-03T00:00:00Z", |
| 248 | + negotiatedRate: false, |
| 249 | + serviceType: "UPS® Ground", |
| 250 | + serviceCode: "ups_ground", |
| 251 | + trackable: true, |
| 252 | + carrierCode: "ups", |
| 253 | + carrierNickname: "ShipEngine Test Account - UPS", |
| 254 | + carrierFriendlyName: "UPS", |
| 255 | + validationStatus: "valid", |
| 256 | + warningMessages: [], |
| 257 | + errorMessages: [], |
| 258 | + }, |
| 259 | + { |
| 260 | + rateId: "se-795561310", |
| 261 | + rateType: "shipment", |
| 262 | + carrierId: "se-423888", |
| 263 | + shippingAmount: { currency: "usd", amount: 83.76 }, |
| 264 | + insuranceAmount: { currency: "usd", amount: 0 }, |
| 265 | + confirmationAmount: { currency: "usd", amount: 0 }, |
| 266 | + otherAmount: { currency: "usd", amount: 0 }, |
| 267 | + taxAmount: null, |
| 268 | + zone: null, |
| 269 | + packageType: null, |
| 270 | + deliveryDays: 1, |
| 271 | + guaranteedService: true, |
| 272 | + estimatedDeliveryDate: "2021-08-04T23:00:00Z", |
| 273 | + carrierDeliveryDays: "Tomorrow by 11:00 PM", |
| 274 | + shipDate: "2021-08-03T00:00:00Z", |
| 275 | + negotiatedRate: false, |
| 276 | + serviceType: "UPS Next Day Air Saver®", |
| 277 | + serviceCode: "ups_next_day_air_saver", |
| 278 | + trackable: true, |
| 279 | + carrierCode: "ups", |
| 280 | + carrierNickname: "ShipEngine Test Account - UPS", |
| 281 | + carrierFriendlyName: "UPS", |
| 282 | + validationStatus: "valid", |
| 283 | + warningMessages: [], |
| 284 | + errorMessages: [], |
| 285 | + }, |
| 286 | + { |
| 287 | + rateId: "se-795561311", |
| 288 | + rateType: "shipment", |
| 289 | + carrierId: "se-423888", |
| 290 | + shippingAmount: { currency: "usd", amount: 96.58 }, |
| 291 | + insuranceAmount: { currency: "usd", amount: 0 }, |
| 292 | + confirmationAmount: { currency: "usd", amount: 0 }, |
| 293 | + otherAmount: { currency: "usd", amount: 0 }, |
| 294 | + taxAmount: null, |
| 295 | + zone: null, |
| 296 | + packageType: null, |
| 297 | + deliveryDays: 1, |
| 298 | + guaranteedService: true, |
| 299 | + estimatedDeliveryDate: "2021-08-04T10:30:00Z", |
| 300 | + carrierDeliveryDays: "Tomorrow by 10:30 AM", |
| 301 | + shipDate: "2021-08-03T00:00:00Z", |
| 302 | + negotiatedRate: false, |
| 303 | + serviceType: "UPS Next Day Air®", |
| 304 | + serviceCode: "ups_next_day_air", |
| 305 | + trackable: true, |
| 306 | + carrierCode: "ups", |
| 307 | + carrierNickname: "ShipEngine Test Account - UPS", |
| 308 | + carrierFriendlyName: "UPS", |
| 309 | + validationStatus: "valid", |
| 310 | + warningMessages: [], |
| 311 | + errorMessages: [], |
| 312 | + }, |
| 313 | + { |
| 314 | + rateId: "se-795561312", |
| 315 | + rateType: "shipment", |
| 316 | + carrierId: "se-423888", |
| 317 | + shippingAmount: { currency: "usd", amount: 41.24 }, |
| 318 | + insuranceAmount: { currency: "usd", amount: 0 }, |
| 319 | + confirmationAmount: { currency: "usd", amount: 0 }, |
| 320 | + otherAmount: { currency: "usd", amount: 0 }, |
| 321 | + taxAmount: null, |
| 322 | + zone: null, |
| 323 | + packageType: null, |
| 324 | + deliveryDays: 2, |
| 325 | + guaranteedService: true, |
| 326 | + estimatedDeliveryDate: "2021-08-05T23:00:00Z", |
| 327 | + carrierDeliveryDays: "Thursday 8/5 by 11:00 PM", |
| 328 | + shipDate: "2021-08-03T00:00:00Z", |
| 329 | + negotiatedRate: false, |
| 330 | + serviceType: "UPS 2nd Day Air®", |
| 331 | + serviceCode: "ups_2nd_day_air", |
| 332 | + trackable: true, |
| 333 | + carrierCode: "ups", |
| 334 | + carrierNickname: "ShipEngine Test Account - UPS", |
| 335 | + carrierFriendlyName: "UPS", |
| 336 | + validationStatus: "valid", |
| 337 | + warningMessages: [], |
| 338 | + errorMessages: [], |
| 339 | + }, |
| 340 | + ], |
| 341 | + invalidRates: [], |
| 342 | + rateRequestId: "se-86697154", |
| 343 | + shipmentId: "se-144012114", |
| 344 | + createdAt: "2021-08-03T19:00:21.3862989Z", |
| 345 | + status: "completed", |
| 346 | + errors: [], |
| 347 | + }, |
| 348 | +}; |
| 349 | +``` |
0 commit comments