1

Using the Shippo API when you request rates it returns multiples and there is an 'attribute' key that contains values such as FASTEST, BESTVALUE, and CHEAPEST. This all seems fine and dandy but I can't seem to locate in the docs whether or not these values will always be present.. ie can I filter by say "BESTVALUE" and always have a result?

1 Answers1

3

When accessing a rate(s), you'll want to remember that they are in the context of a specific shipment. So if you were returning an individual rate using the rate's object_id, then there is no guarantee that there would be any values listed under attributes.

If you were retrieving your rates from the shipment object (under the rates_list field), then you could filter the rates tied to that shipment object listed in the rates_list field using FASTEST, CHEAPEST, BESTVALUE.

Shippo generates these attributes for every shipment, but not necessarily every rate.

mootrichard
  • 3,581
  • 13
  • 25
  • excellent answer - but just to double check, ALL of these attributes will be found within the shipment item objects, none will be missing? I just want to be able to reliably select by these attributes automatically and not leave it up to the customer to choose. – PolarTheDog Jan 27 '17 at 06:18
  • You're right, they are *ALL* included for every shipment object's rates. For each shipment object, it will process through every rate tied to that shipment object to tag the rates appropriately. So there should always be one of each attribute accounted for amongst all the rates tied to that shipment. – mootrichard Jan 27 '17 at 18:03
  • @mootrichard in my experience over two years of using Shippo, your answer has always been correct and applied, until now. For the past few weeks I've been having an issue where **some shipments** (I can't find a pattern) are missing at least the CHEAPEST attribute. We process 100s of orders per day, and this has so far happened 4 times in the past 3-4 weeks. Our code/protocol reverts to taking the first rate, which in all 4 cases has so far been something like "USPS - Priority Mail Express" or similar expedited FedEx service. Any idea why or how that could happen? – Andre Bulatov May 24 '21 at 03:11