mercari_dpop
Mercari DPOP 加密参数生成与店铺信息查询工具库。
安装
pip install mercari_dpop
功能介绍
1. 生成 DPOP JWT — generate_dpop_jwt
根据 RFC 9449 标准,使用 ES256 (P-256) 签名算法生成 DPOP Proof JWT。
函数签名
from mercari_dpop import generate_dpop_jwt
generate_dpop_jwt(user_uuid, http_method, url) -> str
| 参数 | 类型 | 说明 |
|---|---|---|
user_uuid |
str |
用户唯一标识,通常为 str(uuid.uuid4()) |
http_method |
str |
HTTP 请求方法,如 'GET', 'POST' 等 |
url |
str |
请求的目标 URL |
返回值
返回一个 DPOP JWT 字符串(header.payload.signature 格式),可直接放入请求头的 dpop 字段。
示例
import uuid
from mercari_dpop import generate_dpop_jwt
url = "https://api.mercari.jp/users/get_profile"
dpop_token = generate_dpop_jwt(str(uuid.uuid4()), 'GET', url)
print(dpop_token)
# 使用时放入请求头
import requests
headers = {
"dpop": dpop_token,
# ... 其他 headers
}
requests.get(url, headers=headers)
2. 查看账号信息 — get_shop_info
通过 Mercari API 查询指定店铺/用户的公开资料信息,自动处理 DPOP 签名。
函数签名
from mercari_dpop import get_shop_info
get_shop_info(shop_id) -> dict
| 参数 | 类型 | 说明 |
|---|---|---|
shop_id |
str / int |
Mercari 店铺或用户 ID |
返回值
| 场景 | 返回结构 |
|---|---|
| 正常获取 | {'code': None, 'msg': None, ... 店铺详细信息} 或直接返回 data 字典内容 |
| 账号被限制 | {'code': 2, 'msg': '账号被限制'} |
| 请求失败 | {'code': 1, 'msg': 错误信息} |
示例
from mercari_dpop import get_shop_info
result = get_shop_info("914211704")
print(result)
完整示例
from mercari_dpop import generate_dpop_jwt, get_shop_info
import uuid
# 方式一:单独生成 DPOP Token
dpop = generate_dpop_jwt(str(uuid.uuid4()), 'GET', 'https://api.mercari.jp/users/get_profile')
print(f"DPOP JWT: {dpop}")
# 方式二:直接查询店铺信息
info = get_shop_info("914211704")
print(f"店铺信息: {info}")
依赖
- Python >= 3.9
- requests >= 2.33.1
- cryptography >= 47.0.0
License
MIT
Metadata
Release files for mercari-dpop 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mercari_dpop-0.0.6.tar.gz | 6.7 kB | Without provenance | Details for mercari_dpop-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mercari_dpop-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for mercari_dpop-0.0.6-py3-none-any.whl |
Total release size: 12.4 kB
Release files / mercari_dpop-0.0.6.tar.gz
| Download URL | mercari_dpop-0.0.6.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ab1240a8141965c0498dfb34829941abb89de2edb4778b4ba33afaaba3eef0e
|
|
BLAKE2b-256 checksum How to use checksums |
0077f1ab3f33c2fbbad59a8e03f3a1dbad9048d739d8fb37eddf44ba24f93dab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.10
|
Release files / mercari_dpop-0.0.6-py3-none-any.whl
| Download URL | mercari_dpop-0.0.6-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d10d4060386549212ddb6d6c98928dcc416649d162652f7ee1f332357351c2e4
|
|
BLAKE2b-256 checksum How to use checksums |
53b403c1ecbfb04a56328dee482a2ef6d32e463bf84b4e56fd74aa2cbc59003d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.10
|
Security for mercari-dpop 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.