Skip to main content

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.5

  • 3.6

  • 3.7

  • 3.8

  • 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

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.

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

aftership-1.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distributions

aftership-1.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

aftership-1.1.0-py2-none-any.whl (7.2 kB view details)

Uploaded Python 2

File details

Details for the file aftership-1.1.0.tar.gz.

File metadata

  • Download URL: aftership-1.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for aftership-1.1.0.tar.gz
Algorithm Hash digest
SHA256 04aa18a24af6a11848847fbdff15440822f3f1a6227ab79b86e1dad9d0873ffe
MD5 447b4141588e6624f4633127e728ca68
BLAKE2b-256 e774fd1e46ae07f987fa51b0643174e12eae659eda72622db5d5b18b4595e30c

See more details on using hashes here.

File details

Details for the file aftership-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: aftership-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.5.9 Linux/5.4.0-1021-gcp

File hashes

Hashes for aftership-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1685f1d038cb0e900e9e425cf1d3162a4d3fbf049e23e793782aa132246d4398
MD5 f486e408320b3cdee528e6cae20c73e9
BLAKE2b-256 124949e913f02f75561020996e0abac1af87deadd377e5f7c37499375462a5e3

See more details on using hashes here.

File details

Details for the file aftership-1.1.0-py2-none-any.whl.

File metadata

  • Download URL: aftership-1.1.0-py2-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for aftership-1.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 8a505ecb3c223d709d7041f41beeedfe354533fd3e41a136d31d76cd4a09bdc9
MD5 f8897eff346d591b01774a0bc5ed4b75
BLAKE2b-256 d2c3f4390581f08933cce0d0c3b0b159a71ea112171be895fb0cb2ae3c91a4e9

See more details on using hashes here.

Supported by

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