Repository files navigation
$ pip install -r requirements.txt
记下网站域名,类似http://example.com,这就是后面客户端程序使用的domain
使用准备开启API的管理员账户进入cscart管理后台
记下该管理员的用户名,这就是后面客户端程序使用的admin_username
Customers -> Administrators
切换到API access选项卡,选中Yes, allow this user to use the API
记下这里生成的API Key,就是后面客户端程序使用的api_key
点击save changes保存
准备工具curl
curl --user admin_username:api_key -X GET 'http://example.com/api/users'
如果看到JSON格式的返回users用户信息数据,则证明API服务正常
from cscartapi import CscartAPI, CscartAPIException
api = CscartAPI(doamin, admin_username, api_key)
api.get('users')
response = api.commit()
print(response) 这里的response保存的就是测试API服务是否正常获得的users用户信息数据
更多的使用方法请参考examples.py文件中的代码和注释
设置环境变量
CSCART_BASE_URL: Cscart API的链接地址domain
CSCART_USERNAME: Cscart已开启API功能的管理员用户名admin_username
CSCART_API_KEY: Cscart管理员开启API功能时提供的api_key
安装python依赖
$ pip install -r requirements.txt
运行测试命令$ pytest tests
打包发布
支持httpx作为底层数据发送(现在默认使用requests)
完善requests发送机制
添加超时重发或者抛出异常
添加log
About
Cs-cart API Client in Python
Resources
License
Stars
Watchers
Forks
You can’t perform that action at this time.