This is Python implementation for the Shopee Partner REST API.
If you came here looking for the Shopee seller center, to shoping, then go here.
$ pip install pyshopee
import pyshopee
client = pyshopee.Client( shopid, partnerid, API_key )
# get_order_by_status (UNPAID/READY_TO_SHIP/SHIPPED/COMPLETED/CANCELLED/ALL)
resp = client.order.get_order_by_status(order_status="READY_TO_SHIP")
print(resp)
# shop authorize and cancel_authorize url
authorize_url = client.shop.authorize(redirect_url="https://shopee.tw")
print(authorize_url)
cancel_authorize_url = client.shop.cancel_authorize(redirect_url="https://shopee.tw")
print(cancel_authorize_url)
- Simple, reliable, and elegant.
- No need to generate authentication and timestamps by yourself, the wrapper does it for you.
- Module format functionality the same as shopee officail document.
- Good Response exception handling !
1. Shop Management Module : Shop / ShopCategory
2. Orders Management Module : Orders
3. Logistics Management Module : Logistics
5. RMA Management Module : Returns
6. Collection Management Module: toppicks
- pip install from pypi
$ pip install pyshopee
- clone the repository to your local folder
$ cd pyshopee
$ python setup.py install
import pyshopee
client = pyshopee.Client( shopid, partnerid, API_key )
# get_order_by_status (UNPAID/READY_TO_SHIP/SHIPPED/COMPLETED/CANCELLED/ALL)
resp = client.order.get_order_by_status(order_status="READY_TO_SHIP")
print(resp)
# get_order_list
resp = client.order.get_order_list(create_time_from = 1512117303, create_time_to=1512635703)
print(resp)
'''
ordersn_list , type: String[]
The set of order IDs. You can specify, at most, 50 OrderIDs in this call.
'''
# get_order_detail
ordersn_list = [ '1712071633982A7','1712071632981JW','171207163097YCJ']
resp = client.order.get_order_detail(ordersn_list = ordersn_list )
print(resp)
'''
ordersn , type:String []
Shopee's unique identifier for an order.
'''
# get_order_escrow_detail
ordersn = '1712071633982A7'
resp = client.order.get_order_escrow_detail(ordersn = ordersn)
print(resp)
# usage
client.[type].[function name]
[type]
- Shop
- ShopCategory
- Orders
- Logistics
- Item
- Image
- Discount
- Returns
You can find the source code in client.py, and pyshopee have a timeout params in there. Hence, every execute funtion can add an extra timeout setting, depending on your choice.
def execute(self, uri, method, body=None):
''' defalut timeout value will be 10 seconds
'''
parameter = self._make_default_parameter()
if body.get("timeout"):
timeout = body.get("timeout")
body.pop("timeout")
else:
timeout = 10
if body is not None:
parameter.update(body)
req = self._build_request(uri, method, parameter)
prepped = req.prepare()
s = Session()
resp = s.send(prepped, timeout=timeout)
resp = self._build_response(resp)
return resp
For example, we can set the timeout as 20 seconds in the execute requests(default value is 10s).
ordersn = '1712071633982A7'
resp = client.order.get_order_escrow_detail(ordersn = ordersn, timeout=20)
print(resp)
For more details on how to add item via pyshopee, please take a look on folder "example/add.py"
-
From Aug, 2018 ShopeePartnerAPI will change the original apply mechanism.
Please replace with your valid parameter(shopid,partnerid,token etc.)before sumbitting the call. -
To get started, please check the Developer Guide under Documentation - Overview - Developer Guide
on how to become a developer and utilize Shopee OpenAPI services. -
Apply Authority Route:
- Apply Developer Authority
- Develper Authentication
- Build New App's Token
- Developing and Testing
- Seller Authority
- The default parameters are dummies except the PartnerID and Partner Key dedicated to your APP.
Please replace with your valid parameter(shopid etc.) before sumbitting the call. - The testtools is based on PRODUCTION environment, please apply your PRODUCTION credential and parameters The "Request" and "Sign" tab aim to assist developer on verifying the authentication signature of API calls
Source code
https://github.com/JimCurryWang/pyshopee
pypi
https://pypi.org/project/pyshopee
Shopee Parter API Documentation
https://partner.test.shopeemobile.com/docs/
Registration for Shopee Partner API usage
https://docs.google.com/forms/d/e/1FAIpQLSeCSsRHQSoQvZccOSHIl5DZAPIkSnS4ivN0Z6rp6N7JIoofvQ/viewform?c=0&w=1