Skip to main content

temu 开发者sdk temu api

Project description

temu_api

temu 开发者sdk 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.1.0.tar.gz (9.3 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.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: temu_api-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 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.1.0.tar.gz
Algorithm Hash digest
SHA256 63d39e2472ef8ad6fbadddcec5ff2e17f92ee9016a1cd449411c17fbe3b1dfbc
MD5 05efe0dc9e5d2ff2b6ca92ec20111974
BLAKE2b-256 b348d7824ed8a4a29b23d8e800311574fd8b2567e6ffa2b513697f09c0dfb52b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: temu_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23ecb6223d49ae2991e468bc8056cae5bddb1f682bb9706ad390eaab618a8888
MD5 8408428b5aa13fcff802b7c8871aa000
BLAKE2b-256 74935897a5566becf9f2f17906e3078f89b08b4c44bbfe4a3e776dda6f0c9c50

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