Giter VIP home page Giter VIP logo

kaola-sdk's Introduction

Build Status Coverage Status PyPI

网易考拉 Python SDK

目前只支持1.0版本的接口

安装

pip install kaola

使用方法

获取access_token

  1. 首先在考拉开放平台注册账号,注册通过后创建应用,给应用起个名字,获取到appkey和appsecret。
  2. 使用generate_authorization_code_url方法获取获取access code的url,然后访问这个url,用户授权后会自动跳转参数中的redirect_url
    kaola = KaoLa(appkey, appsecret)
    kaola.generate_authorization_code_url(redirect_url)
  3. 在redirect_url的响应事件中先验证state的合法性:
    kaola.check_authorization_state(redirect_url, state)
  4. 第3步获取到的code,使用get_access_token方法获取token
    kaola.get_access_token(code, shop.redirect_url)

调用API

获取到access_token后,传给初始化函数,或使用set_token方法设置到已有KaoLa实例中。

from kaola.api.kaola import KaoLa

kl = KaoLa("edb6c3b9ac4847e7584c38e2b630b14f", "8200ee92ec22fcae76e2f00bc5c79247188e0593",access_token="bff74ff8-bbec-4699-bc4c-529801aefcb4", sandbox=True)
# 搜索订单
kl.order.search_order(
    1, 1, "2019-01-01 0:00:00", "2019-01-30 23:59:59").json()

sandbox 是否是沙箱环境

changelog

  • [0.0.8] 修复订单详细信息查询接口
  • [0.0.3] 修复返回结果格式问题
  • [0.0.4] 更新access token获取机制
  • [0.0.5] 更新说明
  • [0.0.6] 接口返回数据直接返回内层数据

kaola-sdk's People

Contributors

jellyfrank avatar

Stargazers

xu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.