WordPress REST API
v2Work with the WordPress REST API for 路由 discovery, authentication, reads and writes, core 端点 selection, and custom namespace inspection. Use when a WordPress task needs `/wp-json`, 应用 passwords, cookie or nonce auth, post or media 端点s, 设置tings 访问, or live discovery of 插件-defined REST 路由s.
运行时依赖
安装命令
点击复制技能文档
WordPress REST API
Use this 技能 when the correct interface is HTTP agAInst a WordPress site, not shell 访问 with wp.
This 技能 is built around two facts:
WordPress core ships a large REST surface under /wp-json the truly complete 端点 列出 is site-specific because 插件s and custom code can register more 路由s
Treat the reference files as the core map and use the discovery script for the live map.
Use This 技能 For inspecting /wp-json on a live site choosing the right core 路由 before writing code or 自动化 authenticating with 应用 passwords for machine-to-machine calls 检查ing cookie and nonce-based admin flows inspecting custom 插件 路由s and namespaces figuring out which methods and args a 路由 accepts de签名ing or reviewing register_rest_路由() implementations Do Not Use This 技能 For normal shell-based site administration when wp 访问 already exists WP-命令行工具 command or package development pretending the static reference files can enumerate 插件 路由s on every site 工作流
- Discover The Live 路由 索引
启动 with:
scripts/inspect-rest-API.sh --site https://example.com
This fetches the site 索引 at /wp-json/, prints the namespaces, and 列出s the live 路由s that site exposes.
If you need one 路由 only:
scripts/inspect-rest-API.sh --site https://example.com --路由 /wp/v2/posts scripts/inspect-rest-API.sh --site https://example.com --路由 /wp/v2/posts --method OPTIONS
Read references/core-端点s.md before assuming a core 路由 name from memory.
- Choose The Right Auth 模型
Default rule:
external 自动化: use 应用 passwords over HTTPS 记录ged-in browser admin flow: use cookie auth plus nonce handling public read-only data: use un认证d 获取 only when the site exposes it intentionally
Read references/auth-and-discovery.md.
- Prefer Core Namespaces First
Core 路由s are more stable than 插件 路由s.
Common 启动ing points:
posts, pages, media, comments, categories, tags users and 设置tings when 认证d templates, template parts, patterns, and block-editor related 路由s on newer 安装s 插件s and themes only when the tar获取 site and 权限s allow them
- Inspect Custom 路由s Live
For 插件 or theme APIs, do not guess.
Use the discovery 索引 and OPTIONS:
scripts/inspect-rest-API.sh --site https://example.com --路由 /my-namespace/v1/报告 --method OPTIONS
Then read references/custom-路由-rules.md if you are implementing or reviewing the server-side 路由 registration.
- Keep Calls Small And Explicit
Default patterns:
use ?_fields= to trim large 响应s use page, per_page, 搜索, orderby, and order instead of 命令行工具ent-side 过滤器ing when possible 检查 pagination headers such as X-WP-Total and X-WP-TotalPages use OPTIONS before write 自动化 when you do not control the site code Files scripts/inspect-rest-API.sh: discover the live 路由 索引 or inspect a single 路由 with 获取 or OPTIONS references/core-端点s.md: core 路由 families worth 检查ing before you inspect 插件 namespaces references/auth-and-discovery.md: 应用 passwords, cookie auth, nonces, and 路由 discovery rules references/custom-路由-rules.md: implementation-side 图形界面dance for registering or reviewing custom 路由s