Skip to main content

temu 开发者sdk temu api

Project description

temu_api

temu 开发者sdk temu api

pip install temu_api

模块说明

1. Auth 认证模块

from temu_api import TemuClient

APP_KEY = 'your_app_key'
APP_SECRET = 'your_app_secret'
ACCESS_TOKEN = 'your_access_token'
BASE_URL = 'https://openapi-b-us.temu.com'

temu_client = TemuClient(APP_KEY, APP_SECRET, ACCESS_TOKEN, BASE_URL)

# 获取当前 access_token 的权限信息
res = temu_client.auth.get_access_token_info()
print(res)

# 创建 access_token(授权回调)
res = temu_client.auth.create_access_token_info()
print(res)
  • get_access_token_info(**kwargs):获取当前 access_token 的 API 权限列表。
  • create_access_token_info(**kwargs):通过授权回调获取 access_token。

2. Order 订单模块

from temu_api import TemuClient

APP_KEY = 'your_app_key'
APP_SECRET = 'your_app_secret'
ACCESS_TOKEN = 'your_access_token'
BASE_URL = 'https://openapi-b-us.temu.com'

temu_client = TemuClient(APP_KEY, APP_SECRET, ACCESS_TOKEN, BASE_URL)

# 批量获取订单列表
res = temu_client.order.list_orders_v2()
print('list_orders_v2', res)

# 获取订单详情
res = temu_client.order.detail_order_v2(parent_order_sn='PO-211-00822146499192890')
print('detail_order_v2', res)

# 获取订单收货地址
res = temu_client.order.shippinginfo_order_v2(parent_order_sn='PO-211-00822146499192890')
print('shippinginfo_order_v2', res)

# 获取可合并发货的父订单分组
res = temu_client.order.combinedshipment_list_order()
print('combinedshipment_list_order', res)

# 批量获取订单定制商品内容
res = temu_client.order.customization_order(order_sn_list=['xxx', 'yyy'])
print('customization_order', res)

# 获取订单敏感收货地址
res = temu_client.order.decryptshippinginfo_order(parent_order_sn='PO-211-20063653668472890')
print('decryptshippinginfo_order', res)
  • list_orders_v2(...):批量获取订单列表,支持多种筛选参数。
  • detail_order_v2(parent_order_sn, ...):获取指定父订单的详细信息。
  • shippinginfo_order_v2(parent_order_sn, ...):获取指定父订单的收货地址信息。
  • combinedshipment_list_order(...):获取可合并发货的父订单分组。
  • customization_order(order_sn_list, ...):批量获取订单定制商品内容信息。
  • decryptshippinginfo_order(parent_order_sn, ...):获取指定父订单的敏感收货地址信息。

如需更多用法和参数说明,请参考源码注释。

测试用例说明

本项目自带简单的接口测试用例,位于 tests 目录下。

运行测试

  1. 安装依赖:
pip install -r requirements.txt
  1. 运行测试脚本(以 auth 和 order 为例):
python tests/test_auth.py
python tests/test_order.py

tests/test_auth.py 示例

from temu_api import TemuClient

temu_client = TemuClient(APP_KEY, APP_SECRET, ACCESS_TOKEN, BASE_URL)
res = temu_client.auth.get_access_token_info()
print(res)
res = temu_client.auth.create_access_token_info()
print(res)

tests/test_order.py 示例

from temu_api import TemuClient

temu_client = TemuClient(APP_KEY, APP_SECRET, ACCESS_TOKEN, BASE_URL)
res = temu_client.order.list_orders_v2()
# 写入 json 文件
import json
with open('order_list.json', 'w', encoding='utf-8') as f:
    json.dump(res, f, ensure_ascii=False, indent=2)
print(res)
# 其它接口调用见源码

如需自定义参数或更多接口测试,请参考 tests 目录下的源码。

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

temu_api-0.2.0.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

temu_api-0.2.0-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file temu_api-0.2.0.tar.gz.

File metadata

  • Download URL: temu_api-0.2.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for temu_api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e73722212870cc360140a3c53a547654eced76deb6ace773d563f68b15cfdc46
MD5 4730ee328017ff1c74c724af043d18e7
BLAKE2b-256 9ee2dae8b330306a8db5e8b5da1f0c3dbeb333e853c0d7efaff5fe5ecff0bcdd

See more details on using hashes here.

File details

Details for the file temu_api-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: temu_api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for temu_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1af871b5280c035846d6c3222ea802755ff45c0068b1cb8c2eb42514a8008198
MD5 084f3c98ccf877f5761c4ee1e74bac50
BLAKE2b-256 50047e6484439ead4412e3c0e08e97f6d0dd70bf0fe798c6f21459e89e86abba

See more details on using hashes here.

Supported by

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