Ratan's Fork for Commercetools的软件开发工具包
commercetools-ratdev的Python项目详细描述
这是一个用于Commercetools平台的非官方PythonSDK。仅此而已 支持Python3.6+并使用类型注释改进开发 经验。
该api主要使用commercetools api raml文件生成,并使用 用于数据对象的attr库和用于序列化和 反序列化步骤。
安装
pip install commercetools
示例
fromcommercetoolsimportClientclient=Client(project_key="<your-project-key>",client_id="<your-client-id>",client_secret="<your-client-secret>",scope=["<scopes>"],url="https://api.sphere.io",token_url="https://auth.sphere.io/oauth/token",)product=client.products.get_by_id("00633d11-c5bb-434e-b132-73f7e130b4e3")print(product)
也可以通过设置以下环境来配置客户端 变量:
exportCTP_PROJECT_KEY="<project key>"exportCTP_CLIENT_SECRET="<client secret>"exportCTP_CLIENT_ID="<client id>"exportCTP_AUTH_URL="https://auth.sphere.io"exportCTP_API_URL="https://api.sphere.io"exportCTP_SCOPES="<comma seperated list of scopes>"
然后构造一个没有参数的客户机:
fromcommercetoolsimportClientclient=Client()product=client.products.get_by_id("00633d11-c5bb-434e-b132-73f7e130b4e3")print(product)