The official Python library for ShipEngine API.
Project description
ShipEngine Python SDK
ATTN: This project is under development and not ready for consumer use.
- The official Python module for ShipEngine API.
Quick Start
Install shipengine
via pip (not yet published):
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 usingos.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 yourAPI 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 theget_rates_from_shipment
method, you can use one of the returnedrate_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 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 by
carrier_code
andtracking_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.
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
viaPoetry
and install thepre-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 runbin/setup
from the project root as outlined above. -
If you choose not to use
Poetry
and preferpip
you can simply runpip install -r requirements.txt
To be able to commit & push a PR to the repo after making changes locally, you will need to installpre-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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file shipengine-1.0.0.tar.gz
.
File metadata
- Download URL: shipengine-1.0.0.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.7.11 Linux/5.8.0-1039-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92de26fa0f1aefa98072a31aeee8f2a81dc23bed46bac975fdd0a70ff3d7f8a8 |
|
MD5 | cdeff96648e5b26a77e7177f2341ac20 |
|
BLAKE2b-256 | 72d11d79b9af6696136daf149a9af8d08add092f529bcd2e9a313cc90dd0736b |
File details
Details for the file shipengine-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: shipengine-1.0.0-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.7.11 Linux/5.8.0-1039-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b313ad76e0931550036326d46aa3064ce04df07eabedc7f52aad05f24f10b11 |
|
MD5 | 25a11b5f6b65511ff8e958846b7c056d |
|
BLAKE2b-256 | d2e1b9fdadaf1122f9815babd294df5367b5b20a9ba81a48cb792096c917a7f8 |