{"id":13631729,"url":"https://github.com/Shopify/active_shipping","last_synced_at":"2025-04-17T22:31:45.001Z","repository":{"id":393740,"uuid":"11598","full_name":"Shopify/active_shipping","owner":"Shopify","description":"ActiveShipping is a simple shipping abstraction library extracted from Shopify","archived":true,"fork":false,"pushed_at":"2019-12-17T17:07:55.000Z","size":2825,"stargazers_count":812,"open_issues_count":55,"forks_count":547,"subscribers_count":153,"default_branch":"master","last_synced_at":"2024-10-29T21:27:00.857Z","etag":null,"topics":["shipping"],"latest_commit_sha":null,"homepage":"http://shopify.github.io/active_shipping","language":"Ruby","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/Shopify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2008-04-21T18:13:39.000Z","updated_at":"2024-10-09T21:15:00.000Z","dependencies_parsed_at":"2022-07-07T13:35:38.363Z","dependency_job_id":null,"html_url":"https://github.com/Shopify/active_shipping","commit_stats":null,"previous_names":[],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Factive_shipping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Factive_shipping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Factive_shipping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Factive_shipping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shopify","download_url":"https://codeload.github.com/Shopify/active_shipping/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223768650,"owners_count":17199356,"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":["shipping"],"created_at":"2024-08-01T22:02:36.059Z","updated_at":"2024-11-08T23:31:29.607Z","avatar_url":"https://github.com/Shopify.png","language":"Ruby","readme":"# ActiveShipping [![Build status](https://travis-ci.org/Shopify/active_shipping.svg?branch=master)](https://travis-ci.org/Shopify/active_shipping)\n\nThis library interfaces with the web services of various shipping carriers. The goal is to abstract the features that are most frequently used into a pleasant and consistent Ruby API:\n\n- Finding shipping rates\n- Registering shipments\n- Tracking shipments\n- Purchasing shipping labels\n\n## Supported Shipping Carriers\n\n* [USPS](http://www.usps.com)\n* [USPS Returns](http://returns.usps.com)\n* [FedEx](http://www.fedex.com)\n* [Canada Post](http://www.canadapost.ca)\n* [New Zealand Post](http://www.nzpost.co.nz)\n* [Shipwire](http://www.shipwire.com)\n* [Stamps](http://www.stamps.com)\n* [Kunaki](http://www.kunaki.com)\n* [Australia Post](http://auspost.com.au/)\n\n\n## Versions\nNote: `2.x` contains breaking changes, please see the [changelog](https://github.com/Shopify/active_shipping/blob/master/CHANGELOG.md). Shopify will not be actively contributing to the `2.x` version of this gem and is looking for maintainers.\n\n[See our releases](https://github.com/Shopify/active_shipping/releases) for past versions.\n\n## Installation\n\nUsing bundler, add to the `Gemfile`:\n\n```ruby\ngem 'active_shipping'\n```\n\nOr stand alone:\n\n```\n$ gem install active_shipping\n```\n\n\n## Sample Usage\n\n### Compare rates from different carriers\n\n```ruby\nrequire 'active_shipping'\n\n# Package up a poster and a Wii for your nephew.\npackages = [\n  ActiveShipping::Package.new(100,               # 100 grams\n                              [93,10],           # 93 cm long, 10 cm diameter\n                              cylinder: true),   # cylinders have different volume calculations\n\n  ActiveShipping::Package.new(7.5 * 16,          # 7.5 lbs, times 16 oz/lb.\n                              [15, 10, 4.5],     # 15x10x4.5 inches\n                              units: :imperial)  # not grams, not centimetres\n ]\n\n # You live in Beverly Hills, he lives in Ottawa\n origin = ActiveShipping::Location.new(country: 'US',\n                                       state: 'CA',\n                                       city: 'Beverly Hills',\n                                       zip: '90210')\n\n destination = ActiveShipping::Location.new(country: 'CA',\n                                            province: 'ON',\n                                            city: 'Ottawa',\n                                            postal_code: 'K1P 1J1')\n\n # Find out how much it'll be.\n usps = ActiveShipping::USPS.new(login: 'developer-key')\n response = usps.find_rates(origin, destination, packages)\n\n usps_rates = response.rates.sort_by(\u0026:price).collect {|rate| [rate.service_name, rate.price]}\n # =\u003e [[\"USPS Priority Mail International\", 4110],\n #     [\"USPS Express Mail International (EMS)\", 5750],\n #     [\"USPS Global Express Guaranteed Non-Document Non-Rectangular\", 9400],\n #     [\"USPS GXG Envelopes\", 9400],\n #     [\"USPS Global Express Guaranteed Non-Document Rectangular\", 9400],\n #     [\"USPS Global Express Guaranteed\", 9400]]\n```\n\nDimensions for packages are in `Height x Width x Length` order.\n\n### Track a FedEx package\n\n```ruby\nfedex = ActiveShipping::FedEx.new(login: '999999999', password: '7777777', key: '1BXXXXXXXXXxrcB', account: '51XXXXX20')\ntracking_info = fedex.find_tracking_info('tracking-number', carrier_code: 'fedex_ground') # Ground package\n\ntracking_info.shipment_events.each do |event|\n  puts \"#{event.name} at #{event.location.city}, #{event.location.state} on #{event.time}. #{event.message}\"\nend\n# =\u003e Package information transmitted to FedEx at NASHVILLE LOCAL, TN on Thu Oct 23 00:00:00 UTC 2008.\n# Picked up by FedEx at NASHVILLE LOCAL, TN on Thu Oct 23 17:30:00 UTC 2008.\n# Scanned at FedEx sort facility at NASHVILLE, TN on Thu Oct 23 18:50:00 UTC 2008.\n# Departed FedEx sort facility at NASHVILLE, TN on Thu Oct 23 22:33:00 UTC 2008.\n# Arrived at FedEx sort facility at KNOXVILLE, TN on Fri Oct 24 02:45:00 UTC 2008.\n# Scanned at FedEx sort facility at KNOXVILLE, TN on Fri Oct 24 05:56:00 UTC 2008.\n# Delivered at Knoxville, TN on Fri Oct 24 16:45:00 UTC 2008. Signed for by: T.BAKER\n```\n\n## Carrier specific notes\n\n### FedEx connection\n\nThe `:login` key passed to `ActiveShipping::FedEx.new()` is really the FedEx meter number, not the FedEx login.\n\nWhen developing with test credentials, be sure to pass `test: true` to `ActiveShipping::FedEx.new()`.\n\n\n## Tests\n\nYou can run the unit tests with:\n\n```\nbundle exec rake test:unit\n```\n\nand the remote tests with:\n\n```\nbundle exec rake test:remote\n```\n\nThe unit tests mock out requests and responses so that everything runs locally, while the remote tests actually hit the carrier servers. For the remote tests, you'll need valid test credentials for any carriers' tests you want to run. The credentials should go in [`~/.active_shipping/credentials.yml`](https://github.com/Shopify/active_shipping/blob/master/test/credentials.yml). For some carriers, we have public credentials you can use for testing in `.travis.yml`. Remote tests missing credentials will be skipped.\n\n\n## Contributing\n\nSee [CONTRIBUTING.md](https://github.com/Shopify/active_shipping/blob/master/CONTRIBUTING.md).\n\nWe love getting pull requests! Anything from new features to documentation clean up.\n\nIf you're building a new carrier, a good place to start is in the [`Carrier` base class](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/carrier.rb).\n\nIt would also be good to familiarize yourself with [`Location`](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/location.rb), [`Package`](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/package.rb), and [`Response`](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/response.rb).\n\nYou can use the [`test/console.rb`](https://github.com/Shopify/active_shipping/blob/master/test/console.rb) to do some local testing against real endpoints.\n\nTo log requests and responses, just set the `logger` on your Carrier class to some kind of `Logger` object:\n\n```ruby\nActiveShipping::USPS.logger = Logger.new(STDOUT)\n```\n\n### Anatomy of a pull request\n\nAny new features or carriers should have passing unit _and_ remote tests. Look at some existing carriers as examples.\n\nWhen opening a pull request, include description of the feature, why it exists, and any supporting documentation to explain interaction with carriers.\n\n\n### How to contribute\n\n1. Fork it ( https://github.com/Shopify/active_shipping/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FShopify%2Factive_shipping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FShopify%2Factive_shipping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FShopify%2Factive_shipping/lists"}