Skip to content

AfterShip/aftership-sdk-python

Repository files navigation

aftership-sdk-python

image

image

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.

Via source code

Download the code archive, without unzip it, go to the source root directory, then run:

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

You can also set API key via setting AFTERSHIP_API_KEY environment varaible.

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 http_status
meta.code code
meta.type message

Keyword arguments

Most of SDK functions only accept keyword arguments.

Examples

Goto examples to see more examples.