python flipkart marketplace api客户端
python-flipkart的Python项目详细描述
python flipkart marketplace api客户端
- 免费软件:BSD许可证
- 文档:https://python-flipkart.readthedocs.org。
安装
来自PYPI:
$ pip install python-flipkart
来自源代码(高级用户和开发):
$ git clone https://github.com/fulfilio/python-flipkart.git
$ cd python-flipkart
$ python setup.py install
示例用法
fromflipkartimportFlipkartAPI,Authenticationauth=Authentication('app id','app secret',sandbox=True)token=auth.get_token_from_client_credentials()flipkart=FlipkartAPI(token['access_token'],sandbox=True,debug=True)orders=flipkart.search_orders()
获取sku
的列表sku=flipkart.sku('my-special-sku',fsn='TSHDBN3326TEZHQZ')forlistinginsku.listings:printlisting.attributes['mrp']
创建列表
sku=flipkart.sku('my-special-sku',fsn='TSHDBN3326TEZHQZ')listing=sku.create_listing(mrp=2400,selling_price=2300,listing_status="INACTIVE",fulfilled_by="seller",national_shipping_charge=20,zonal_shipping_charge=20,local_shipping_charge=20,procurement_sla=3,stock_count=23,)listing.save()printlisting.mrp
更新列表
listing=flipkart.listing('LSTTSHDBN332XDYBZ5MHX30XI')listing.attributes['mrp']=2600listing.save()
搜索订单
orders=flipkart.search_orders()
仅查找所选SKU的订单:
orders=flipkart.search_orders(filters={'sku':['my-sku-1','my-sku-2']})
按状态筛选:
orders=flipkart.search_orders(filters={'states':['Approved']})
提示
有关有效状态的列表,请参见API documentation
获取特定订单项
order_item=flipkart.order_item('1731')order_item.attributes['quantity']
或者一次获得多个订单项
order_items=flipkart.order_items('1731','1732')
一旦订单准备好打包,就生成一个标签
label_request=order_item.generate_label(date.today(),# Invoice date'INV12345',# Invoice number)
如果有需要序列号的项目
label_request=order_item.generate_label(date.today(),# Invoice date'INV12345',# Invoice number[['IMEI1']],)
如果物品是双SIM卡
label_request=order_item.generate_label(date.today(),# Invoice date'INV12345',# Invoice number[['IMEI1','IMEI2']],)
如果2部双SIM卡手机
label_request=order_item.generate_label(date.today(),# Invoice date'INV12345',# Invoice number[['IMEI1','IMEI2'],['IMEI3','IMEI4']],)
generate_label的响应是一个标签请求。标签请求 是一个懒惰的api。可以通过调用刷新状态
label_request.refresh_status()
一旦状态被清除,就可以发货了。去拿标签 要发送,请调用get_label方法获取标签的pdf 可能是发票。
pdf=order_item.get_label()
一旦您的货物准备好供Flipkart物流合作伙伴挑选, 调用就绪的dispatchapi。
order_item.dispatch()
获取发货详细信息
Shipments API提供Orderitems的装运详细信息
order_item.get_shipment_details()
可以在Flipkart API documentation上看到响应项
获取访问令牌
如果您已使用卖家凭证和 要访问您帐户中的资源,可以使用 只有应用程序id和secret才能这样做。中的身份验证帮助程序 api为您提供了一种获取令牌的方便方法
fromauthimportAuthenticationauth=Authentication('<application id>','<application secret>',sandbox=True,# If you are using sandbox)auth.get_token_from_client_credentials()
功能
- 待办事项
历史记录
0.2.0
- 使用完整的订单项API进行主要更新
- 向自述文件中添加了示例
0.1.2
- 使版本号一致。
0.1.1
- 将包重命名为python flipkart。