{"id":19100171,"url":"https://github.com/alexeybusygin/ShippingRates","last_synced_at":"2025-04-18T17:32:54.062Z","repository":{"id":42136658,"uuid":"240738325","full_name":"alexeybusygin/ShippingRates","owner":"alexeybusygin","description":".NET wrapper for UPS, FedEx, USPS and DHL shipping rate APIs","archived":false,"fork":false,"pushed_at":"2024-10-09T20:15:34.000Z","size":417,"stargazers_count":46,"open_issues_count":5,"forks_count":15,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-05T22:14:35.585Z","etag":null,"topics":["dhl","dhl-ecommerce","dotnet","dotnet-standard","fedex","shipping","shipping-rates","ups","usps"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexeybusygin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-15T15:34:06.000Z","updated_at":"2024-10-09T20:15:36.000Z","dependencies_parsed_at":"2024-07-07T20:29:41.181Z","dependency_job_id":"e33c9df2-c5f7-4fee-961a-d40d7d6809bf","html_url":"https://github.com/alexeybusygin/ShippingRates","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeybusygin%2FShippingRates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeybusygin%2FShippingRates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeybusygin%2FShippingRates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeybusygin%2FShippingRates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexeybusygin","download_url":"https://codeload.github.com/alexeybusygin/ShippingRates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223783092,"owners_count":17201903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dhl","dhl-ecommerce","dotnet","dotnet-standard","fedex","shipping","shipping-rates","ups","usps"],"created_at":"2024-11-09T03:52:32.394Z","updated_at":"2025-04-18T17:32:54.057Z","avatar_url":"https://github.com/alexeybusygin.png","language":"C#","funding_links":[],"categories":["dotnet"],"sub_categories":[],"readme":"# ShippingRates\n\n[![Build](https://github.com/alexeybusygin/ShippingRates/actions/workflows/build.yml/badge.svg)](https://github.com/alexeybusygin/ShippingRates/actions/workflows/build.yml)\n[![NuGet Version](https://img.shields.io/nuget/v/ShippingRates.svg?style=flat-square)](https://www.nuget.org/packages/ShippingRates)\n\n.NET wrapper for UPS, FedEx, USPS, and DHL APIs. Use it to retrieve shipping rates from these carriers.\n\n## UPS Breaking Changes\n\nUPS has deprecated access key authentication in favor of an OAuth 2.0 security model for all APIs. Beginning August 5, 2024, access keys will no longer be supported. More details at the UPS site: https://developer.ups.com/oauth-developer-guide?loc=en_US\n\nThe new authentication model was implemented in the package starting with version 2.1.0.\n\n## How to Install\n\nAvailable in the [NuGet Gallery](http://nuget.org/packages/ShippingRates):\n\n```\nPM\u003e Install-Package ShippingRates\n```\n\n## Getting Started\n\n```CSharp\n// Create RateManager\nusing var httpClient = new HttpClient();\nvar rateManager = new RateManager();\n\n// Add desired shipping providers\n// You will need an OAuth Client ID, Client Secret, and Account Number to use the UPS provider.\nvar upsConfiguration = new UPSProviderConfiguration()\n{\n    ClientId = upsClientId,\n    ClientSecret = upsClientSecret,\n    AccountNumber = upsAccountNumber,\n    UseProduction = false\n};\nrateManager.AddProvider(new UPSProvider(upsConfiguration, httpClient));\n\n// You will need an account # and meter # to utilize the FedEx provider.\nrateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber));\n\n// You will need a userId to use the USPS provider. Your account will also need access to the production servers.\nrateManager.AddProvider(new USPSProvider(new USPSProviderConfiguration(uspsUserId), httpClient));\n\n// You will need a Site ID and Password to use the DHL provider.\nvar dhlConfiguration = new DHLProviderConfiguration(dhlSiteId, dhlPassword, useProduction: false));\nrateManager.AddProvider(new DHLProvider(dhlConfiguration, httpClient));\n\n// Setup package and destination/origin addresses\nvar packages = new List\u003cPackage\u003e();\npackages.Add(new Package(12, 12, 12, 35, 150));    // Package in lbs and inches\npackages.Add(new PackageKgCm(4, 4, 6, 15, 250));   // Package in kg and cm\n\nvar origin = new Address(\"\", \"\", \"06405\", \"US\");\nvar destination = new Address(\"\", \"\", \"20852\", \"US\"); // US Address\n\n// Call GetRates()\nShipment shipment = await rateManager.GetRatesAsync(origin, destination, packages);\n\n// Iterate through the rates returned\nforeach (Rate rate in shipment.Rates)\n{\n    Console.WriteLine(rate);\n}\n```\n\nSee the sample app in this repository for a working example.\n\n## Documentation in [Wiki](https://github.com/alexeybusygin/ShippingRates/wiki)\n\n* [HttpClient lifecycle](https://github.com/alexeybusygin/ShippingRates/wiki/HttpClient-lifecycle)\n* [Negotiated Rates](https://github.com/alexeybusygin/ShippingRates/wiki/Negotiated-Rates)\n* [Logging](https://github.com/alexeybusygin/ShippingRates/wiki/Logging)\n* [USPS: International Rates](https://github.com/alexeybusygin/ShippingRates/wiki/USPS-International-Rates)\n* [USPS: Special Services](https://github.com/alexeybusygin/ShippingRates/wiki/USPS-Special-Services)\n* [Single Rate for UPS and USPS](https://github.com/alexeybusygin/ShippingRates/wiki/Single-Rate-for-UPS-and-USPS)\n* [Rate Adjusters](https://github.com/alexeybusygin/ShippingRates/wiki/Rate-Adjusters)\n\n## Shipping Options\n\nShipping options can be passed to the `GetRates` function as a `ShipmentOptions` object.\n\n```CSHARP\nvar shipment = await rateManager.GetRatesAsync(origin, destination, packages,\n    new ShipmentOptions() {\n        SaturdayDelivery = true,\n        ShippingDate = new DateTime(2020, 7, 15),\n        PreferredCurrencyCode = \"EUR\",                  // For FedEx only\n        FedExOneRate = true,                            // For FedEx only\n        FedExOneRatePackageOverride = \"FEDEX_ENVELOPE\"  // For FedEx only\n    });\n```\n\nThe following options are available:\n\n| Name | Default Value | Meaning |\n| ---- | ------------- | ------- |\n| SaturdayDelivery | False | Enable the Saturday Delivery option for shipping rates. |\n| ShippingDate | null | Pickup date. The current date and time are used if not specified. |\n| PreferredCurrencyCode | USD | Preferred rates currency code in the ISO format. Applies to FedEx only. |\n| FedExOneRate | False | Use the FedEx One Rate pricing option. Applies to FedEx only. |\n| FedExOneRatePackageOverride | FEDEX_MEDIUM_BOX | Packing option when using FedEx OneRate. |\n\n### Saturday Delivery\n\nIf `ShipmentOptions.SaturdayDelivery` is set, you can expect to receive some Saturday Delivery methods. You can check it with the `Rate.Options.SaturdayDelivery` property:\n\n```CSHARP\nvar anySaturdayDeliveryMethods = shipment.Rates.Any(r =\u003e r.Options.SaturdayDelivery);\n```    \n\n## Error Handling\n\nNormally, `RateManager.GetRates` wouldn't throw any exceptions. All errors are caught and reported in two properties: `Errors` and `InternalErrors`. `Errors` are for errors coming from APIs (incorrect address, etc.) It should be quite safe to show them to the end user. `InternalErrors` are errors that occur during API calls processing (SOAP, HTTP requests) and errors from inside the ShippingRates. They can be used for debugging and internal reporting. Iterating through Errors and InternalErrors:\n\n```CSHARP\nvar shipment = rateManager.GetRates(origin, destination, packages);\n\nforeach (var error in shipment.Errors)\n{\n    Console.WriteLine(error.Number);\n    Console.WriteLine(error.Source);\n    Console.WriteLine(error.Description);\n}\n\nforeach (var error in shipment.InternalErrors)\n{\n    Console.WriteLine(error);\n}\n```\n\n#### FedEx and 556 There are no valid services available\n\nThis one can be tricky to debug. Start by setting at least $1 insurance for your shipment. For some reason, FedEx will not report errors like the wrong ZIP code for the origin address if no insurance is set.\n\n## 3rd Party Docs\n\nDeveloper documentation is often hard to find. The links below are provided as a reference.\n\n* [FedEx](http://www.fedex.com/us/developer/)\n* [USPS](https://www.usps.com/business/web-tools-apis/welcome.htm)\n* [UPS](https://developer.ups.com/api/reference?loc=en_US#operation/Rate)\n* [DHL](https://xmlportal.dhl.com/capability_and_qoute#cap_quote)\n\n## Credits\n\nOriginally forked from [DotNetShipping](https://github.com/kylewest/DotNetShipping) by [@kylewest](https://github.com/kylewest).\nPackage icon by [Fredy Sujono](https://www.iconfinder.com/freud).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexeybusygin%2FShippingRates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexeybusygin%2FShippingRates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexeybusygin%2FShippingRates/lists"}