Skip to main content

Kaola Python SDK

Project description

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] 接口返回数据直接返回内层数据

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kaola-0.0.9.tar.gz (9.1 kB view details)

Uploaded Source

File details

Details for the file kaola-0.0.9.tar.gz.

File metadata

  • Download URL: kaola-0.0.9.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.7

File hashes

Hashes for kaola-0.0.9.tar.gz
Algorithm Hash digest
SHA256 92a2dacc11593f37e3248c704d826e525d5445e35953e0f82ebf97bef9ef2885
MD5 10bf85bce52f4781e43621724d7be37b
BLAKE2b-256 d9fa2e339465fffa021fd69014b38381fd0fe44c72a5a8b3cfd8be7af1f702fb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page