用于python的easypost shipping api客户端库

easypost的Python项目详细描述


EasyPost Python客户端库

Build Status

easypost是简单的装运api。你可以在https://easypost.com注册一个帐户。

要求

正在为另一种语言查找客户端库?签出https://www.easypost.com/docs/libraries

安装

您可以使用以下命令通过pip安装easypost:

pip install easypost

或者,您可以克隆easypost python客户机存储库:

git clone https://github.com/EasyPost/easypost-python

安装:

python setup.py install

导入EasyPost客户端:

importeasypost

示例

importeasyposteasypost.api_key='<YOUR API KEY FROM https://www.easypost.com/account/api-keys>'# create and verify addressesto_address=easypost.Address.create(verify=["delivery"],name="Dr. Steve Brule",street1="179 N Harbor Dr",street2="",city="Redondo Beach",state="CA",zip="90277",country="US",phone="310-808-5243")from_address=easypost.Address.create(verify=["delivery"],name="EasyPost",street1="118 2nd Street",street2="4th Floor",city="San Francisco",state="CA",zip="94105",country="US",phone="415-456-7890")# create parceltry:parcel=easypost.Parcel.create(predefined_package="Parcel",weight=21.2)excepteasypost.Errorase:print(str(e))ife.paramisnotNone:print('Specifically an invalid param: %r'%e.param)parcel=easypost.Parcel.create(length=10.2,width=7.8,height=4.3,weight=21.2)# create customs_info form for intl shippingcustoms_item=easypost.CustomsItem.create(description="EasyPost t-shirts",hs_tariff_number=123456,origin_country="US",quantity=2,value=96.27,weight=21.1)customs_info=easypost.CustomsInfo.create(customs_certify=1,customs_signer="Hector Hammerfall",contents_type="gift",contents_explanation="",eel_pfc="NOEEI 30.37(a)",non_delivery_option="return",restriction_type="none",restriction_comments="",customs_items=[customs_item])# create shipmentshipment=easypost.Shipment.create(to_address=to_address,from_address=from_address,parcel=parcel,customs_info=customs_info)# buy postage label with one of the rate objectsshipment.buy(rate=shipment.rates[0])# alternatively: shipment.buy(rate = shipment.lowest_rate())print(shipment.tracking_code)print(shipment.postage_label.label_url)# Insure the shipment for the valueshipment.insure(amount=100)print(shipment.insurance)

文件

最新文档位于:https://www.easypost.com/docs

客户端库开发

释放

  1. CHANGELOG.md添加新功能
  2. VERSION
  3. 创建git标记
  4. python setup.py sdist upload
  5. 推到pypi

运行测试

运行测试:

  • 为您的python版本创建一个virtualenv(例如,python2.7 -m virtualenv venv
  • 在该虚拟机中安装依赖项(./venv/bin/pip install requests six
  • 安装测试依赖项(./venv/bin/pip install -r requirements-tests.txt
  • 使用py.test./venv/bin/py.test -vs tests)运行测试

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何从数组中打印int值?   prepared语句Java中奇怪的异常PreparedStatement:参数索引超出范围   封装如何在OOP Java中为主方法编码?   java某些手机显示快捷方式徽章需要什么权限?   java TextView不会随OnItemSelectedListener更改   java注释处理器不会自动触发吗?   java Spring JPA如何计算外键数   c#对于这个简单的OOAD问题,哪种设计最优雅?   java如何处理while循环中的异常?   Android Studio错误:进程'command'/home/draven/Downloads/安卓studio/jre/bin/java''结束,退出值为非零2   在使用Payara服务器的Vaadin应用程序中导航到根目录时,java将丢失上下文根目录   使用contentType application/json而不是application/jsonpatch+json的java修补程序   带有tomcat的java HAproxy连接不足   Java:在应用过滤器后创建一个简单的通用方法进行计数   java如何使用多态性创建一个实例化对象的方法,然后用它们高效地填充ArrayList?