Skip to main content

The official Python library for ShipEngine API.

Project description

ShipEngine

ShipEngine Python SDK

GitHub Workflow Status Coverage Status GitHub OS Compatibility

  • The official Python module for ShipEngine API.

Quick Start

Install shipengine via pip:

pip install shipengine
  • The only configuration requirement is providing an API Key.

The following assumes that you have already set the SHIPENGINE_API_KEY environment variable with your API Key using os.environ["SHIPENGINE_API_KEY"] = "<YOUR_API_KEY_HERE>".

Instantiate ShipEngine Class

import os

from shipengine import ShipEngine

api_key = os.getenv("SHIPENGINE_API_KEY")

shipengine = ShipEngine(api_key)
  • You can also pass in a dictionary containing configuration options instead of just passing in a string that is your API Key.
import os

from shipengine import ShipEngine

api_key = os.getenv("SHIPENGINE_API_KEY")

shipengine = ShipEngine(
    {"api_key": api_key, "page_size": 75, "retries": 3, "timeout": 10}
)

Methods

  • addresses_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 by rate_id. When using the get_rates_from_shipment method, you can use one of the returned rate_id values 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 by label_id, the preferred way to track shipments if you create 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 by carrier_code and tracking_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 its label_id. This method returns an object that indicates the status of the void label request.
  • [list_labels_by_tracking_number] (./docs/list_labels_by_tracking_number.md) - List the labels associated with the inputted tracking number.

Class Objects

  • ShipEngine - A configurable entry point to the ShipEngine API SDK, this class provides convenience methods for various ShipEngine API Services.

Contributing

Local Development

You will need to install Python3.7 if you do not have it locally, before working on this project.

This project uses Poetry to manage project dependencies, build steps, and publishing to PYPI.

You can use the following curl command to download Poetry from your terminal is you are on osx / linux / bashonwindows:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
  • Once you have Poetry installed you need to install the projects dependencies with this command from the project root:
bin/setup
  • This script will install all dependencies specified in pyproject.toml via Poetry and install the pre-commit hooks this project uses.

Adding dependencies to the project

If your changes require you to install a python package/module using poetry add <some package> or poetry add <some package> -D for a dev dependency. You will also need to run the following command to regenerate a requirements.txt file that includes the newly added dependencies:

poetry export -f requirements.txt --output requirements.txt --without-hashes --dev

Pre-Commit Hooks

We are using Pre-Commit to enforce formatting, lint rules, and code analysis so that this repo is always in good health.

  • Pre-Commit is installed and initialized when you run bin/setup from the project root as outlined above.

  • If you choose not to use Poetry and prefer pip you can simply run pip install -r requirements.txt To be able to commit & push a PR to the repo after making changes locally, you will need to install pre-commit which is a tool that runs tests, linting, formatting, and code analysis on your changes.

pre-commit install

Note: The checks run in pre-commit hooks are the same checks run in CI in our GitHub Actions.

Testing

You can run the tests in the tests/ directory using Pytest in the Poetry environment like this:

poetry run pytest

OR via Tox:

poetry run tox

Linting

You can run the linting environment in Tox using this command:

poetry tox -e lint

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shipengine-2.0.5.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shipengine-2.0.5-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file shipengine-2.0.5.tar.gz.

File metadata

  • Download URL: shipengine-2.0.5.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for shipengine-2.0.5.tar.gz
Algorithm Hash digest
SHA256 16c994d1572ac59ec66b94a6da8f01dbbb54a31063d13d9f106e941b95cb34e5
MD5 102c4f86bafda8eae63a86b58331c07c
BLAKE2b-256 4157bcfe2be6e956b42a789a0d2c7363ba9f665879e5082ecd8f6af979b08ab0

See more details on using hashes here.

File details

Details for the file shipengine-2.0.5-py3-none-any.whl.

File metadata

  • Download URL: shipengine-2.0.5-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for shipengine-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 898940cc2367e43c9889812b3f08b3e5b82315ea9627753d690c61f2b8714325
MD5 d1e462810d7852127de9fa3b04856dd7
BLAKE2b-256 87bce519849ebc5654f53f7f2d911c3b3a1ace42f5a1738c8d3ddbcbf3e4df2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page