Skip to content

Latest commit

 

History

History
executable file
·
229 lines (164 loc) · 6.29 KB

README.md

File metadata and controls

executable file
·
229 lines (164 loc) · 6.29 KB

pyshopee v1.3.9

PyPI GitHub Depfu

Shopee Partners API - python implementation

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)

Features

  • 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 !

6 main parts of implementation

1. Shop Management Module : Shop / ShopCategory

2. Orders Management Module : Orders

3. Logistics Management Module : Logistics

4. Products Management Module : Item / Image / Discount

5. RMA Management Module : Returns

6. Collection Management Module: toppicks

Installation

  1. pip install from pypi
$ pip install pyshopee
  1. clone the repository to your local folder
$ cd pyshopee
$ python setup.py install

Quick Start

Import pyshopee & get order by status

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

# get_order_list
resp = client.order.get_order_list(create_time_from = 1512117303, create_time_to=1512635703)
print(resp)

Get order detail

'''
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)

Get order escrow detail

'''
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)

Advance Details for others functions

# usage
client.[type].[function name]

[type]
  - Shop
  - ShopCategory
  - Orders
  - Logistics
  - Item
  - Image
  - Discount
  - Returns

Advance parameters you must want to know

Timeout

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)

Add Item Example

For more details on how to add item via pyshopee, please take a look on folder "example/add.py"

Developer Note

  • 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:

    1. Apply Developer Authority
    2. Develper Authentication
    3. Build New App's Token
    4. Developing and Testing
    5. Seller Authority

About testtools platform

  • 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

Note

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