Bing Webmaster CLI Skill
Use this skill to operate and troubleshoot the bwm CLI in this repository.
When To Use
Use this skill when the task involves any of:
- - creating or rotating a Bing Webmaster API key
- authenticating this CLI with env var or local stored key
- listing sites in Bing Webmaster
- fetching site/URL traffic stats
- checking whether a URL is indexed and why not
- submitting URLs for indexing
Prerequisites
- - Python environment with this project installed (
bwm command available) - Bing Webmaster Tools account with access to at least one site
- Bing Webmaster API key
Install This CLI
Recommended (pipx, global bwm command):
CODEBLOCK0
From source (development):
CODEBLOCK1
From source (pipx, editable):
CODEBLOCK2
Create API Key (Bing Webmaster)
As of February 26, 2026, create a Bing Webmaster API key using these steps:
- 1. Open Bing Webmaster Tools: INLINECODE5
- Sign in and open account/API access settings.
- Generate a new API key.
- Copy and securely store the key.
Reference:
Authenticate This CLI
Environment variable (recommended for CI/ephemeral usage)
CODEBLOCK3
Local stored key
CODEBLOCK4
Interactive prompt:
CODEBLOCK5
Clear local key:
CODEBLOCK6
Optional: Set Default Site
CODEBLOCK7
When set, commands that accept --site can omit it.
Command Reference
Top-level:
auth
- - INLINECODE11
- INLINECODE12
- INLINECODE13
config
- - INLINECODE15
- INLINECODE16
site
stats
- - INLINECODE20
- INLINECODE21
url
- - INLINECODE23
- INLINECODE24
Quick Examples
CODEBLOCK8
Troubleshooting
- set
BING_WEBMASTER_API_KEY or run
bwm auth login.
- pass
--site or set default site with
bwm config set default-site ....
- - URL appears blocked in Bing UI while simple API fields are sparse
- run
bwm url check-index --explain ... to get best-effort diagnostics from API signals.
Config Paths And Overrides
Defaults:
- - credentials: INLINECODE32
- app config: INLINECODE33
Env overrides:
- - INLINECODE34
- INLINECODE35
- INLINECODE36
- INLINECODE37
- INLINECODE38
Bing Webmaster CLI 技能
使用此技能来操作和排查本仓库中的 bwm CLI。
使用时机
当任务涉及以下任何内容时使用此技能:
- - 创建或轮换 Bing Webmaster API 密钥
- 使用环境变量或本地存储的密钥对此 CLI 进行身份验证
- 列出 Bing Webmaster 中的站点
- 获取站点/URL 流量统计
- 检查 URL 是否已被索引及未索引的原因
- 提交 URL 进行索引
前提条件
- - 已安装此项目的 Python 环境(bwm 命令可用)
- 拥有至少一个站点访问权限的 Bing Webmaster Tools 账户
- Bing Webmaster API 密钥
安装此 CLI
推荐方式(pipx,全局 bwm 命令):
bash
python3 -m pip install --user pipx
python3 -m pipx ensurepath
pipx install bing-webmaster-cli
bwm --version
从源码安装(开发模式):
bash
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
bwm --help
从源码安装(pipx,可编辑模式):
bash
pipx install -e /absolute/path/to/bingwebmastercli
bwm --help
创建 API 密钥(Bing Webmaster)
截至 2026 年 2 月 26 日,按以下步骤创建 Bing Webmaster API 密钥:
- 1. 打开 Bing Webmaster Tools:https://www.bing.com/webmasters/
- 登录并打开账户/API 访问设置。
- 生成新的 API 密钥。
- 复制并安全存储密钥。
参考:
- - https://learn.microsoft.com/en-us/bingwebmaster/getting-access
验证此 CLI
环境变量(推荐用于 CI/临时使用)
bash
export BINGWEBMASTERAPIKEY=api_key>
bwm auth whoami
本地存储密钥
bash
bwm auth login --api-key apikey>
bwm auth whoami
交互式提示:
bash
bwm auth login
清除本地密钥:
bash
bwm auth clear
可选:设置默认站点
bash
bwm config set default-site https://example.com/
bwm config get default-site
设置后,接受 --site 参数的命令可以省略该参数。
命令参考
顶层命令:
- - bwm --version
- bwm --help
auth
- - bwm auth login [--api-key TEXT]
- bwm auth whoami [--output table|json]
- bwm auth clear
config
- - bwm config set default-site SITE_URL
- bwm config get default-site
site
- - bwm site list [--output table|json|csv] [--csv-path FILE]
stats
- - bwm stats site [--site SITE] [--start-date YYYY-MM-DD] [--end-date YYYY-MM-DD] [--output table|json|csv] [--csv-path FILE]
- bwm stats url [--site SITE] --url URL [--start-date YYYY-MM-DD] [--end-date YYYY-MM-DD] [--output table|json|csv] [--csv-path FILE]
url
- - bwm url check-index [--site SITE] --url URL [--output table|json] [--explain]
- bwm url submit [--site SITE] [--url URL]... [--file FILE] [--output table|json]
快速示例
bash
列出站点
bwm site list --output json
指定日期范围的站点统计
bwm stats site \
--site https://example.com/ \
--start-date 2026-02-01 \
--end-date 2026-02-26
URL 统计
bwm stats url \
--site https://example.com/ \
--url https://example.com/page \
--output json
URL 索引检查及详细说明
bwm url check-index \
--site https://example.com/ \
--url https://example.com/page \
--output json \
--explain
提交单个 URL
bwm url submit --site https://example.com/ --url https://example.com/new-page
从文件批量提交
bwm url submit --site https://example.com/ --file ./urls.txt
故障排除
- - Auth error: No API key found...
- 设置 BING
WEBMASTERAPI_KEY 或运行 bwm auth login。
- - No site specified. Pass --site or set one...
- 传递 --site 或使用 bwm config set default-site ... 设置默认站点。
- - URL 在 Bing UI 中显示被屏蔽,但简单 API 字段信息不足
- 运行 bwm url check-index --explain ... 以从 API 信号获取最佳诊断信息。
配置路径和覆盖
默认路径:
- - 凭据:~/.config/bing-webmaster-cli/credentials.json
- 应用配置:~/.config/bing-webmaster-cli/config.json
环境变量覆盖:
- - BINGWEBMASTERAPIKEY
- BWMCONFIGDIR
- BWMCREDENTIALSFILE
- BWMAPPCONFIGFILE
- BWMAPIBASE_URL