import shippo
from shippo.models import operations
s = shippo.Shippo(
api_key_header='ShippoToken <API_TOKEN>',
shippo_api_version='2018-02-08',
)
res = s.rates.list_shipment_rates_by_currency_code(request=operations.ListShipmentRatesByCurrencyCodeRequest(
shipment_id='<id>',
currency_code='USD',
))
if res is not None:
# handle response
pass{
"next": "baseurl?page=3&results=10",
"previous": "baseurl?page=1&results=10",
"results": [
{
"amount": "5.5",
"amount_local": "5.5",
"currency": "USD",
"currency_local": "USD",
"attributes": [
"BESTVALUE"
],
"carrier_account": "078870331023437cb917f5187429b093",
"object_created": "2023-11-07T05:31:56Z",
"object_id": "adcfdddf8ec64b84ad22772bce3ea37a",
"object_owner": "pp@gmail.com",
"provider": "USPS",
"servicelevel": {
"name": "Priority Mail Express",
"terms": "<string>",
"token": "usps_priority_express",
"extended_token": "<string>",
"parent_servicelevel": {
"name": "Priority Mail Express",
"terms": "<string>",
"token": "usps_priority_express",
"extended_token": "<string>"
}
},
"shipment": "adcfdddf8ec64b84ad22772bce3ea37a",
"arrives_by": "08:30:00",
"duration_terms": "Delivery in 1 to 3 business days",
"estimated_days": 2,
"included_insurance_price": "1.05",
"messages": [
{
"source": "UPS",
"code": "carrier_timeout",
"text": "UPS API did not respond. Please try again in a few minutes."
}
],
"provider_image_75": "https://cdn2.goshippo.com/providers/75/USPS.png",
"provider_image_200": "https://cdn2.goshippo.com/providers/200/USPS.png",
"test": true,
"zone": "1"
}
]
}Returns all available shipping rates for a shipment object.
When you create a new valid shipment object, Shippo automatically calculates all available rates. Depending on your shipment data, there may be none, one or multiple rates.
By default, the calculated rates will return the price in two currencies under the amount and amount_local keys, respectively. The amount key will contain the price of a rate expressed in the currency that is used in the country from where the parcel originates, and the amount_local key will contain the price expressed in the currency that is used in the country the parcel is shipped to. You can request rates with prices expressed in a different currency by adding the currency code to the end of the resource URL. The full list of supported currencies along with their codes can be viewed on open exchange rates.
Note: re-requesting the rates with a different currency code will re-queue the shipment (i.e. set the Shipment’s status to QUEUED) and the converted currency rates will only be available when the Shipment’s status is set to SUCCESS.
Rates for shipments older than 390 days are not returned.
import shippo
from shippo.models import operations
s = shippo.Shippo(
api_key_header='ShippoToken <API_TOKEN>',
shippo_api_version='2018-02-08',
)
res = s.rates.list_shipment_rates_by_currency_code(request=operations.ListShipmentRatesByCurrencyCodeRequest(
shipment_id='<id>',
currency_code='USD',
))
if res is not None:
# handle response
pass{
"next": "baseurl?page=3&results=10",
"previous": "baseurl?page=1&results=10",
"results": [
{
"amount": "5.5",
"amount_local": "5.5",
"currency": "USD",
"currency_local": "USD",
"attributes": [
"BESTVALUE"
],
"carrier_account": "078870331023437cb917f5187429b093",
"object_created": "2023-11-07T05:31:56Z",
"object_id": "adcfdddf8ec64b84ad22772bce3ea37a",
"object_owner": "pp@gmail.com",
"provider": "USPS",
"servicelevel": {
"name": "Priority Mail Express",
"terms": "<string>",
"token": "usps_priority_express",
"extended_token": "<string>",
"parent_servicelevel": {
"name": "Priority Mail Express",
"terms": "<string>",
"token": "usps_priority_express",
"extended_token": "<string>"
}
},
"shipment": "adcfdddf8ec64b84ad22772bce3ea37a",
"arrives_by": "08:30:00",
"duration_terms": "Delivery in 1 to 3 business days",
"estimated_days": 2,
"included_insurance_price": "1.05",
"messages": [
{
"source": "UPS",
"code": "carrier_timeout",
"text": "UPS API did not respond. Please try again in a few minutes."
}
],
"provider_image_75": "https://cdn2.goshippo.com/providers/75/USPS.png",
"provider_image_200": "https://cdn2.goshippo.com/providers/200/USPS.png",
"test": true,
"zone": "1"
}
]
}API key authentication using the ShippoToken scheme. Format: Authorization: ShippoToken <API_TOKEN> Example: Authorization: ShippoToken shippo_live_abc123
Optional string used to pick a non-default API version to use. See our API version guide.
"2018-02-08"
Object ID of the shipment to update
ISO currency code for the rates
The page number you want to select
The number of results to return per page (max 100)
x <= 100Was this page helpful?