微算力 · API 导航与自营网关
API 接入 EN
未登录登录
📦

自动化管理 Amazon 订单历史

Amazon Orders · v1.0.0
办公 安全 B 级 作者 pfernandez98 公开目录收录
下载 2.1k 安装 0 收藏 8.7k 浏览 15
原始页面

简介

通过非官方Python API和CLI下载、查询Amazon订单历史,支持Python库与命令行双模式,适合自动化个人财务追踪与订单管理。

原始描述

Download and query your Amazon order history via an unofficial Python API and CLI.

中文使用说明 来自收录源

核心用法

amazon-orders 是一个非官方工具,通过网页抓取(scraping)方式访问 Amazon.com 的订单数据。提供两种使用模式:

Python 库模式:导入 AmazonSession 和 AmazonOrders 类,创建会话、登录后调用 get_order_history() 方法,支持按年份(year=2023)或时间过滤器(last30、months-3)查询订单。设置 full_details=True 可获取更完整的订单字段。

CLI 模式:通过 amazon-orders 命令行工具执行 login、history 等操作,支持 --year、--last-30-days、--full-details 等参数,可配合 jq 等工具实现 JSON 导出与数据处理。

显著优点

  1. 双模支持:同时提供编程接口和命令行工具,满足不同技术背景用户需求
  2. 时间过滤灵活:内置多种预设时间范围,支持精确年份查询
  3. 数据导出便捷:原生输出 JSON 格式,易于与其他工具链集成
  4. MFA 自动化支持:通过 AMAZON_OTP_SECRET_KEY 环境变量支持 TOTP,可实现无人值守运行

潜在缺点与局限性

  • 稳定性风险:依赖网页抓取,Amazon 页面结构变更会导致功能失效
  • 地域限制:仅官方支持 Amazon.com(美国站),其他区域站点兼容性未保证
  • 功能边界:非官方 API,无法访问 Amazon 未在网页端展示的数据
  • 性能考量:full_details 模式需额外页面请求,速度较慢

适合人群

  • 需要批量导出 Amazon 订单数据进行个人财务分析的用户
  • 希望自动化订单追踪的技术用户与开发者
  • 使用美国 Amazon 账户的英语用户

常规风险

  1. 账户安全:需提供 Amazon 登录凭证,存在凭证泄露风险;建议通过环境变量或密钥管理服务注入,避免硬编码
  2. 服务条款:网页抓取可能违反 Amazon 服务条款,存在账户限制风险
  3. OTP 密钥管理:AMAZON_OTP_SECRET_KEY 为敏感信息,泄露将导致 MFA 保护失效
  4. 数据准确性:依赖页面解析,存在因页面结构变化导致数据缺失或错误的可能

技能正文


name: amazon-orders description: Download and query your Amazon order history via an unofficial Python API and CLI. homepage: https://github.com/alexdlaird/amazon-orders metadata: {"clawdbot":{"emoji":"📦","requires":{"bins":["python3","pip3"],"env":["AMAZON_USERNAME", "AMAZON_PASSWORD", "AMAZON_OTP_SECRET_KEY"]}}}

amazon-orders Skill

Interact with your Amazon.com order history using the unofficial amazon-orders Python package and CLI.

Note: amazon-orders works by scraping/parsing Amazon's consumer website, so it can break if Amazon changes their pages. Only the English Amazon .com site is officially supported.

Setup

Install / upgrade

python3 -m pip install --upgrade amazon-orders

(Install details and version pinning guidance are in the project README.)

Authentication options

amazon-orders can get credentials from (highest precedence first): environment variables, parameters passed to AmazonSession, or a local config.

Environment variables:

export AMAZON_USERNAME="you@example.com"
export AMAZON_PASSWORD="your-password"
# Optional: for accounts with OTP/TOTP enabled
export AMAZON_OTP_SECRET_KEY="BASE32_TOTP_SECRET"

(OTP secret key usage is documented by the project.)

Usage

You can use amazon-orders either as a Python library or from the command line.

Python: basic usage

from amazonorders.session import AmazonSession
from amazonorders.orders import AmazonOrders

amazon_session = AmazonSession("<AMAZON_EMAIL>", "<AMAZON_PASSWORD>")
amazon_session.login()

amazon_orders = AmazonOrders(amazon_session)

# Orders from a specific year
orders = amazon_orders.get_order_history(year=2023)

# Or use a time filter for recent orders
orders = amazon_orders.get_order_history(time_filter="last30")     # Last 30 days
orders = amazon_orders.get_order_history(time_filter="months-3")   # Past 3 months

for order in orders:
    print(f"{order.order_number} - {order.grand_total}")

Full details (slower, more fields)

Some order fields only populate when you request full details; enable it when you need richer order data:

  • Python: full_details=True
  • CLI: --full-details on history

CLI: common commands

# Authenticate (interactive / uses env vars if set)
amazon-orders login

# Order history
amazon-orders history --year 2023
amazon-orders history --last-30-days
amazon-orders history --last-3-months

Tips

  • If your account has MFA enabled, prefer setting AMAZON_OTP_SECRET_KEY for automated runs.
  • When automating, keep credentials out of shell history: use environment variables and a secret manager (1Password, Vault, GitHub Actions secrets, etc.).

Examples

Export yearly history to JSON

amazon-orders history --year 2023 --full-details > orders_2023.json

Quick totals check (requires jq)

amazon-orders history --last-30-days --full-details   | jq -r '.[] | [.order_number, .grand_total] | @tsv'

Notes

  • This is an unofficial scraper-based tool (no official Amazon API).
  • Official docs are hosted on Read the Docs for advanced usage and APIs (Orders, Transactions, etc.).

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

其他来源收录

同一技能在不同目录的原始页面:

标签

amazone-commercedata-exportautomationpythoncliweb-scrapingorder-trackingpersonal-finance

同类 Skill