The python SDK of AfterShip API
Project description
aftership-sdk-python is Python SDK (module) for AfterShip API. Module provides clean way to access API endpoints.
IMPORTANT NOTE
Current version of aftership-sdk-python >=0.3 not compatible with previous version of sdk <=0.2.
Also, version since 1.0 is not support Python 2.X anymore. If you want to use this SDK under Python 2.X, please use versions <1.0.
Supported Python Versions
3.6
3.7
3.8
3.9
3.10
pypy3
Installation
Via pip
Use Virtual Environment
We recommend using a virtualenv or poem to use this SDK.
$ pip install aftership
Via source code
Download the code archive, without unzip it, go to the source root directory, then run:
$ pip install aftership-sdk-python.zip
Usage
You need a valid API key to use this SDK. If you don’t have one, please visit https://www.aftership.com/apps/api.
Quick Start
The following code gets list of supported couriers
import aftership
aftership.api_key = 'YOUR_API_KEY_FROM_AFTERSHIP'
couriers = aftership.courier.list_couriers()
You can also set API key via setting AFTERSHIP_API_KEY
environment varaible.
export AFTERSHIP_API_KEY=THIS_IS_MY_API_KEY
import aftership
tracking = aftership.get_tracking(tracking_id='your_tracking_id')
The functions of the SDK will return data field value if the API endpoints
return response with HTTP status 2XX
, otherwise will throw an
exception.
Exceptions
Exceptions are mapped from https://docs.aftership.com/api/4/errors, and this table is the exception attributes mapping.
API error |
AfterShipError |
---|---|
http status code |
|
|
|
|
|
Keyword arguments
Most of SDK functions only accept keyword arguments.
Examples
Goto examples to see more examples.
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
Hashes for aftership-1.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c1038aa3b94efd0dc0cf1ceeb7fa4f686d11cc54fc74dfdee9b790bfdaa0bf9 |
|
MD5 | 1fcd7b3b0e7f043a64f4b3766801b248 |
|
BLAKE2b-256 | d3644a1ea6040b335ee874256f7c4ca4311153591206de6161036bdec40d126e |