Majatech VendorHub API Python SDK — 商户接入与业务接口调用客户端
Project description
Majatech VendorHub Python SDK
Majatech VendorHub API 的 Python 客户端库,支持商户接入、签名认证、Token 管理及业务接口调用。
安装
pip install majatech_vendorhub
快速开始
from majatech_vendorhub import VendorHub
client = VendorHub(
access_key="your-access-key",
access_secret="your-access-secret",
vendor_code="your-vendor-code",
country_code="your-country-code",
)
try:
response = client.request_api(
api_code="Some.Api.Code",
data={"test_filed": "test_content"},
)
print(response.code) # 0 表示成功
print(response.message) # 响应消息
print(response.data) # 业务数据
print(response.raw) # 原始响应
finally:
client.close()
支持上下文管理器
with VendorHub(
access_key="...",
access_secret="...",
vendor_code="...",
country_code="...",
) as client:
response = client.request_api("Some.Api.Code", data={})
异常处理
from majatech_vendorhub import (
VendorHubError,
AuthenticationError,
TokenExpiredError,
APIRequestError,
)
try:
response = client.request_api("Some.Api.Code", data={})
except AuthenticationError as e:
print(f"认证失败: {e}, 错误码: {e.code}")
except APIRequestError as e:
print(f"API 错误: {e}, 错误码: {e.code}")
except VendorHubError as e:
print(f"业务错误: {e}")
依赖
- Python >= 3.8
- requests >= 2.25.0
构建与发布
# 构建
python -m build
# 发布到 PyPI
python -m twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file majatech_vendorhub-1.0.6.tar.gz.
File metadata
- Download URL: majatech_vendorhub-1.0.6.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fa5e5d390a5025cd0d79463057a762452aca8cd031229df9bd785b20c1757a6
|
|
| MD5 |
51db2cfac2a9701f2c18af939a30f393
|
|
| BLAKE2b-256 |
a306324dbccf57f7f384745793cc31eaf8cb59fb9d200fa33a4f42c95d9dfa84
|
File details
Details for the file majatech_vendorhub-1.0.6-py3-none-any.whl.
File metadata
- Download URL: majatech_vendorhub-1.0.6-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53c1c0cbbd6f079ffd6b7e0c8ce8f137eb9dd4eb71024399b1ec4b1f62b771e5
|
|
| MD5 |
e25a2c5c7e91054e1e21b2d4e5076be6
|
|
| BLAKE2b-256 |
8627a4a227cec3b9b8ca198b64f007b976191c9631d67bf336d668dd14877726
|