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.1.1.tar.gz (14.1 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.1-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: temu_api-0.1.1.tar.gz
  • Upload date:
  • Size: 14.1 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.1.tar.gz
Algorithm Hash digest
SHA256 1579387138e33a081dfe0326e520ff32a9896b79119200456e3932e0512ad7bf
MD5 6e79f633d9846850426b194b1c1c4606
BLAKE2b-256 298f5335c5b922cb4f544f810895400bef44eb0f1aecfe3594e968aa58d74d52

See more details on using hashes here.

File details

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

File metadata

  • Download URL: temu_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3427053d5a73510ce95bd44feff672d46afde3bb411f43fc8fed7f66f6e32db
MD5 2fc2fc748417278ef0772956b43a93e7
BLAKE2b-256 aa3f281cb39f82def9af5b6d721eec656a8e6b52b0d8a85b0fa0c4f723eed933

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