Skip to main content

The python SDK of AfterShip API

Project description

https://travis-ci.com/AfterShip/aftership-sdk-python.svg?branch=master https://coveralls.io/repos/github/AfterShip/aftership-sdk-python/badge.svg?branch=master

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

  • 3.9

  • 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.2.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

aftership-1.2.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aftership-1.2.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.2 Darwin/19.6.0

File hashes

Hashes for aftership-1.2.1.tar.gz
Algorithm Hash digest
SHA256 d7c8ce662925894d83a97279dfe78db03a061a2b405f3b63561b38970e2a7d84
MD5 798753b579bd0fb00d909a37ab053d07
BLAKE2b-256 80ee54869f4931d5f20fc9b7a26a5adf108e762ca771b43a1c89ac14a5532d92

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aftership-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.2 Darwin/19.6.0

File hashes

Hashes for aftership-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0937504bd46ebad7f6a13f6e0106605c1a18fc53e70033cdd9a26fd60f7d8536
MD5 5b332254e58fd762a640a70995be4c0a
BLAKE2b-256 396f7f878cda08df483ee60257764ab4a692e0220cb5a1e471d67b86443d4ccb

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