Skip to main content

UpsRating Python SDK 1.0.0

Welcome to the UpsRating SDK documentation. This guide will help you get started with integrating and using the UpsRating SDK in your project.

Versions

  • SDK version: 1.0.0

About the API

Compare delivery services and shipping rates to determine the best option. In order to obtain your bearer token please follow the instructions at https://developer.ups.com/get-started, or use the UPS Authorization API.

Table of Contents

Setup & Configuration

Supported Language Versions

This SDK is compatible with the following versions: Python >= 3.7

Installation

To get started with the SDK, we recommend installing using pip:

pip install ups-rating

Authentication

Access Token Authentication

The UpsRating API uses an Access Token for authentication.

This token must be provided to authenticate your requests to the API.

Setting the Access Token

When you initialize the SDK, you can set the access token as follows:

UpsRating(
access_token="YOUR_ACCESS_TOKEN"
)

If you need to set or update the access token after initializing the SDK, you can use:

sdk.set_access_token("YOUR_ACCESS_TOKEN")

Services

The SDK provides various services to interact with the API.

Below is a list of all available services with links to their detailed documentation:

Models

The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.

Below is a list of all available models with links to their detailed documentation:
NameDescription
RateRequestWrapperN/A
RateResponseWrapperN/A
RateRequestRate Request container.
RateRequestRequestRequest container. N/A
RateRequestPickupTypePickup Type container tag.
RateRequestCustomerClassificationCustomer classification container. Valid if ShipFrom country or territory is "US"
RateRequestShipmentContainer for Shipment Information.
RequestTransactionReferenceTransactionReference identifies transactions between client and server.
ShipmentShipperShipper container. Information associated with the UPS account number.
ShipmentShipToShip To Container
ShipmentShipFromShip From Container.
ShipmentAlternateDeliveryAddressAlternate Delivery Address container. Applies for deliveries to UPS Access Point™ locations. Required for the following ShipmentIndicationType values: - 01 - Hold for Pickup at UPS Access Point™ - 02 - UPS Access Point™ Delivery
ShipmentShipmentIndicationTypeContainer to hold shipment indication type.
ShipmentPaymentDetailsPayment details container for detailed shipment charges. The two shipment charges that are available for specification are Transportation charges and Duties and Taxes. This container is used for Who Pays What functionality.
ShipmentFrsPaymentInformationUPS Ground Freight Pricing (GFP) Payment Information container. Required only for GFP and when the FRSIndicator is present.
ShipmentFreightShipmentInformationContainer to hold Freight Shipment information.
ShipmentServiceService Container. Only valid with RequestOption = Rate for both Small package and GFP Rating requests.
ShipmentShipmentTotalWeightShipment Total Weight Container. This container is only applicable for "ratetimeintransit" and "shoptimeintransit" request options. Required for all international shipments when retreiving time in transit information, including letters and documents shipments.
ShipmentPackagePackage Container. Only one Package allowed for Simple Rate
ShipmentShipmentServiceOptionsShipment level Accessorials are included in this container.
ShipmentShipmentRatingOptionsShipment Rating Options container.
ShipmentInvoiceLineTotalContainer to hold InvoiceLineTotal Information. Required if the shipment is from US/PR Outbound to non US/PR destination with the PackagingType of UPS PAK(04).Required for international shipments when using request option "ratetimeintransit" or "shoptimeintransit".
ShipmentPromotionalDiscountInformationPromotionalDiscountInformation container. This container contains discount information that the customer wants to request each time while placing a shipment.
ShipmentDeliveryTimeInformationContainer for requesting Time In Transit Information. Required to view time in transit information. Required to view any time in transit information.
ShipperAddressAddress Container. If the ShipFrom container is not present then this address will be used as the ShipFrom. If this address is used as the ShipFrom, the shipment will be rated from this origin address.
ShipToAddressAddress Container.
ShipFromAddressAddress container for Ship From. Address Container
AlternateDeliveryAddressAddressAddress container for Alternate Delivery Address.
PaymentDetailsShipmentChargeShipment charge container. If Duty and Tax charges are applicable to a shipment and a payer is not specified, the default payer of Duty and Tax charges is Bill to Receiver. There will be no default payer of Duty and Tax charges for DDU and DDP service.
ShipmentChargeBillShipperContainer for the BillShipper billing option. This element or its sibling element, BillReceiver, BillThirdParty or ConsigneeBilledIndicator, must be present but no more than one can be present.
ShipmentChargeBillReceiverContainer for the BillReceiver billing option. This element or its sibling element, BillShipper, BillThirdParty or Consignee Billed, must be present but no more than one can be present. For a return shipment, Bill Receiver is invalid for Transportation charges.
ShipmentChargeBillThirdPartyContainer for the third party billing option. This element or its sibling element, BillShipper, BillReceiver or Consignee Billed, must be present but no more than one can be present.
BillReceiverAddressContainer for additional information for the bill receiver's UPS accounts address.
BillThirdPartyAddressContainer for additional information for the third party UPS accounts address.
FrsPaymentInformationTypeGFP Payment Information Type container. GFP only.
FrsPaymentInformationAddressPayer Address Container. Address container may be present for FRS Payment Information type = 02 and required when the FRS Payment Information type = 03.
FreightShipmentInformationFreightDensityInfoFreight Density Info container. Required if DensityEligibleIndicator is present.
FreightDensityInfoAdjustedHeightContainer to hold Adjusted Height information. Required if AdjustedHeightIndicator is present.
FreightDensityInfoHandlingUnitsHandling Unit for Density based rating container.
AdjustedHeightUnitOfMeasurementUnit of Measurement container for the Adjusted height.
HandlingUnitsTypeHandling Unit Type for Density based rating.
HandlingUnitsDimensionsDimension of the HandlingUnit container for density based pricing.
HandlingUnitsUnitOfMeasurementUnitOfMeasurement container.
ShipmentTotalWeightUnitOfMeasurementUnitOfMeasurement Container.
PackagePackagingTypePackaging Type Container.
PackageDimensionsDimensions Container. This container is not applicable for GFP Rating request. Required for Heavy Goods service. Package Dimension will be ignored for Simple Rate
PackageDimWeightPackage Dimensional Weight container. Values in this container are ignored when package dimensions are provided. Please visit ups.com for instructions on calculating this value. Only used for non-US/CA/PR shipments.
PackagePackageWeightPackage Weight Container. Required for an GFP Rating request. Otherwise optional. Required for Heavy Goods service. Package Weight will be ignored for Simple Rate
PackageCommodityCommodity Container. Required only for GFP rating when FRSShipmentIndicator is requested.
PackagePackageServiceOptionsPackageServiceOptions container.
PackageSimpleRateSimpleRate Container
PackageUpsPremierUPS Premier
DimensionsUnitOfMeasurementUnitOfMeasurement container.
DimWeightUnitOfMeasurementUnitOfMeasurement Container.
PackageWeightUnitOfMeasurementUnitOfMeasurement Container.
CommodityNmfcNMFC Commodity container. For GFP Only.
PackageServiceOptionsDeliveryConfirmationDelivery Confirmation Container. For a list of valid origin/destination countries or territories please refer to appendix. DeliveryConfirmation and COD are mutually exclusive.
PackageServiceOptionsAccessPointCodAccess Point COD indicates Package COD is requested for a shipment. Valid only for : 01 - Hold For Pickup At UPS Access Point, Shipment Indication type. Package Access Point COD is valid only for shipment without return service from US/PR to US/PR and CA to CA. Not valid with (Package) COD.
PackageServiceOptionsCodCOD Container. Indicates COD is requested. Valid for the following country or territory combinations: US/PR to US/PRCA to CACA to USNot allowed for CA to US for packages that are designated as Letters or Envelopes.
PackageServiceOptionsDeclaredValueDeclared Value Container.
PackageServiceOptionsShipperDeclaredValueShipper Paid Declared Value Charge at Package level. Valid for UPS World Wide Express Freight shipments.
PackageServiceOptionsInsuranceInsurance Accesorial. Only one type of insurance can exist at a time on the shipment. Valid for UPS World Wide Express Freight shipments.
PackageServiceOptionsHazMatContainer to hold HazMat information. Applies only if SubVersion is greater than or equal to 1701.
PackageServiceOptionsDryIceContainer to hold Dry Ice information. Lane check will happen based on postal code/ city.
CodCodAmountCODAmount Container.
InsuranceBasicFlexibleParcelIndicatorContainer to hold Basic Flexible Parcel Indicator information. Valid for UPS World Wide Express Freight shipments.
InsuranceExtendedFlexibleParcelIndicatorContainer for Extended Flexible Parcel Indicator Valid for UPS World Wide Express Freight shipments.
InsuranceTimeInTransitFlexibleParcelIndicatorContainer to hold Time In Transit Flexible Parcel Indicator information. Valid for UPS World Wide Express Freight shipments.
HazMatHazMatChemicalRecordContainer to hold HazMat Chemical Records.
DryIceDryIceWeightContainer for Weight information for Dry Ice.
DryIceWeightUnitOfMeasurementContainer for Unit Of Measurement for Dry Ice.
ShipmentServiceOptionsAccessPointCodAccess Point COD indicates Shipment level Access Point COD is requested for a shipment. Valid only for "01 - Hold For Pickup At UPS Access Point" Shipment Indication type. Shipment Access Point COD is valid only for countries or territories within E.U. Not valid with (Shipment) COD. Not available to shipment with return service.
ShipmentServiceOptionsCodIf present, indicates C.O.D. is requested for the shipment. Shipment level C.O.D. is only available for EU origin countries or territories.C.O.D. shipments are only available for Shippers with Daily Pickup and Drop Shipping accounts.
ShipmentServiceOptionsDeliveryConfirmationDelivery Confirmation Container. DeliveryConfirmation and C.O.D. are mutually exclusive. Refer to the Appendix for a list of valid origin-destination country or territory pairs associated with each confirmation type.
ShipmentServiceOptionsPickupOptionsShipment Service Pickup Options Container. Valid for UPS Worldwide Express Freight and UPS Worldwide Express Freight Midday shipments.
ShipmentServiceOptionsDeliveryOptionsShipment Service Delivery Options Container. Valid for UPS Worldwide Express Freight and UPS Worldwide Express Freight Midday shipments.
ShipmentServiceOptionsRestrictedArticlesRestricted Articles container. Valid for UPS World Wide Express Freight shipments.
ShipmentServiceOptionsImportControlContainer for type of Import Control shipments.
ShipmentServiceOptionsReturnServiceContainer for type of Return Services.
ShipmentServiceOptionsCodCodAmountCODAmount Container. UPS does not support all international currency codes. Refer to the appendix for a list of valid codes.
DeliveryTimeInformationPickupPickup container.
DeliveryTimeInformationReturnContractServicesReturn contract services container
RateResponseRate Response Container.
RateResponseResponseResponse Container.
RateResponseRatedShipment
ResponseResponseStatusResponse Status Container.
ResponseAlertAlert container. There can be zero to many alert containers with code and description.
ResponseAlertDetail
ResponseTransactionReferenceTransaction Reference Container.
AlertDetailElementLevelInformationProvides more information about the element that represents the alert.
ElementLevelInformationElementIdentifier
RatedShipmentDisclaimer
RatedShipmentServiceService Container.
RatedShipmentRatedShipmentAlert
RatedShipmentBillingWeightBilling Weight Container.
RatedShipmentTransportationChargesTransportation Charges Container.
RatedShipmentBaseServiceChargeBase Service Charge Container. These charges would be returned only when subversion is greater than or equal to 1701
RatedShipmentItemizedCharges
RatedShipmentFrsShipmentDataFRSShipmentData container. Only returned when the FRSShipmentIIndicator is used. UPS Ground Freight Pricing Only.
RatedShipmentServiceOptionsChargesService Options Charges Container.
RatedShipmentTaxCharges
RatedShipmentTotalChargesTotal Charges Container.
RatedShipmentTotalChargesWithTaxesTotalChargesWithTaxes container would be returned only if TaxInformationIndicator is present in request and when Negotiated Rates are not applicable. TotalChargesWithTaxes contains total charges including total taxes applied to a shipment.
RatedShipmentNegotiatedRateChargesNegotiated Rate Charges Container. For tiered rates and promotional discounts, if a particular shipment based on zone, origin, destination or even shipment size doesn't qualify for the existing discount then no negotiated rates container will be returned. Published rates will be the applicable rate.
RatedShipmentRatedPackage
RatedShipmentTimeInTransitContainer for returned Time in Transit information. Will only be returned if request option was either "ratetimeintransit" or "shoptimeintransit" and DeliveryTimeInformation container was present in request.
BillingWeightUnitOfMeasurementUnit Of Measurement Container.
FrsShipmentDataTransportationChargesTransportation Charges Container
FrsShipmentDataFreightDensityRateFreightDensityRate container for Density based rating.
FrsShipmentDataHandlingUnits
TransportationChargesGrossChargeGross Transportation Charges Container
TransportationChargesDiscountAmountDiscount Container
TransportationChargesNetChargeNet Transportation Rate Container
HandlingUnitsAdjustedHeightContainer to hold Adjusted Height information.
NegotiatedRateChargesItemizedCharges
NegotiatedRateChargesTaxCharges
NegotiatedRateChargesTotalChargeTotal Charges Container.
NegotiatedRateChargesTotalChargesWithTaxesTotalChargesWithTaxes container would be returned only if TaxInformationIndicator is present in request. TotalChargesWithTaxes contains total charges including total taxes applied to a shipment.
RatedPackageBaseServiceChargeBase Service Charge Container. These charges would be returned only when subversion is greater than or equal to 1701
RatedPackageTransportationChargesTransportation Charges Container.
RatedPackageServiceOptionsChargesService Options Charges Container.
RatedPackageTotalChargesTotal Charges Container.
RatedPackageBillingWeightBilling Weight Container.
RatedPackageAccessorial
RatedPackageItemizedCharges
RatedPackageNegotiatedChargesNegotiated Rates container. These charges would be returned only when -1) subversion is greater than or equal to 16072) if negotiated rates were requested for GFP shipments and account number is eligible to receive negotiated rates.
RatedPackageSimpleRateSimpleRate will be returned if Simple Rate present in request
RatedPackageRateModifier
RatedPackageBillingWeightUnitOfMeasurementUnit Of Measurement Container.
NegotiatedChargesItemizedCharges
TimeInTransitServiceSummaryContainer for all available service information.
ServiceSummaryServiceContainer for the the UPS service selected for a shipment.
ServiceSummaryEstimatedArrivalContainer for the Time-In-Transit arrival information by service
EstimatedArrivalArrivalContainer for the Time-In-Transit arrival information by service. This is the most accurate delivery information available via the Rating API and will reflect changes in delivery schedules due to peak business seasons or holidays.
EstimatedArrivalPickupThe date and pick up time container.

License

This SDK is licensed under the MIT License.

See the LICENSE file for more details.

Build Your Own SDKs with  liblab

Build developer friendly SDKs in minutes from your APIs

Start for Free →