Package: shipengine
ShipEngine Python SDKATTN: This project is under development and not ready for consumer use.The official Python module for ShipEngine API.Quick StartInstallshipenginevia pip (not yet published):pipinstallshipengineThe only configuration requirement is providing anAPI Key.The following assumes that you have already set theSHIPENGINE_API_KEYenvironment variable with your API Key usingos.environ["SHIPENGINE_API_KEY"] = "<YOUR_API_KEY_HERE>".Instantiate ShipEngine ClassimportosfromshipengineimportShipEngineapi_key=os.getenv("SHIPENGINE_API_KEY")shipengine=ShipEngine(api_key)You can also pass in adictionarycontaining configuration options instead of just passing in a string that is yourAPI Key.importosfromshipengineimportShipEngineapi_key=os.getenv("SHIPENGINE_API_KEY")shipengine=ShipEngine({"api_key":api_key,"page_size":75,"retries":3,"timeout":10})Methodsaddresses_validate- Indicates whether the provided address is valid. If the
address is valid, the method returns a normalized version of the address based on the standards of the country in
which the address resides.create_label_from_rate_id- Purchase a label byrate_id. When using theget_rates_from_shipmentmethod, you can use one of the returnedrate_idvalues with this method to purchase a label against a given rate.create_label_from_shipment- Purchase a label created from shipment details.get_rates_from_shipment- Fetch rates from shipment details to shop the best shipping rate for your package.list_carriers- Lists the carrier accounts connected to your SHipEngine account.track_package_by_label_id- Track a package bylabel_id, the preferred way to track shipments if you crate shipping labels using ShipEngine. This method returns
the all tracking events for a given shipment.track_package_by_carrier_code_and_tracking_number- Track a package bycarrier_codeandtracking_number. This method returns
the all tracking events for a given shipment.void_label_by_label_id- Void a shipping label you created using ShipEngine by itslabel_id. This method returns an object that indicates the status of the void label request.Class ObjectsShipEngine- A configurable entry point to the ShipEngine API SDK, this class provides convenience methods
for various ShipEngine API Services.ContributingLocal DevelopmentYou will need to installPython3.7if you do not have it locally, before working on this project.This project usesPoetryto manage project dependencies, build steps, and publishing toPYPI.You can use the followingcurlcommand to downloadPoetryfrom your terminal is you are
onosx / linux / bashonwindows:curl-sSLhttps://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py|python-Once you havePoetryinstalled you need to install the projects dependencies with this command from the project root:bin/setupThis script will install all dependencies specified inpyproject.tomlviaPoetryand install thepre-commithooks
this project uses.Adding dependencies to the projectIf your changes require you to install a python package/module usingpoetry add <some package>orpoetry add <some package> -Dfor a dev dependency. You will also need to run the following command to
regenerate arequirements.txtfile that includes the newly added dependencies:poetryexport-frequirements.txt--outputrequirements.txt--without-hashes--devPre-Commit HooksWe are usingPre-Committo enforce formatting, lint rules, and code analysis so that
this repo is always in good health.Pre-Commitis installed and initialized when you runbin/setupfrom the project root as outlined above.If you choose not to usePoetryand preferpipyou can simply runpip install -r requirements.txtTo be able to commit & push a PR to the repo after making changes locally, you will need to installpre-commitwhich
is a tool that runs tests, linting, formatting, and code analysis on your changes.pre-commitinstallNote: The checks run in pre-commit hooks are the same checks run in CI in our GitHub Actions.TestingYou can run the tests in thetests/directory usingPytestin thePoetryenvironment like this:poetryrunpytestOR viaTox:poetryruntoxLintingYou can run thelinting environmentinToxusing this command:poetrytox-elint