一般对于 wp-json 来说, ["POST", "PUT", "PATCH", "DELETE"]都需要授权,目前(4.1版本)暂时没有授权方案, 只能依靠第三方插件处理授权问题。授权处理请查看 WordPress 使用 JWT Authentication 或 Nonces 验证 WordPress REST API
而 GET 则大部分不需要授权,如果涉及到用户信息或后天配置信息,这些获取仍需要授权。
AJAX 的形式获取 JSON 数据有网站信息、用户信息、文章信息、评论信息、目录信息、标签信息、单页面信息、分类信息、媒体信息,全部参数链接详解如文章内容;
0 网站信息
- https://wordpress.crlang.com/wp-json
1 文章
1.1 获取最新文章(默认获取到最新的10篇文章)
- https://wordpress.crlang.com/wp-json/wp/v2/posts
GET 参数如下:
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }, "page": {
- "default": 1,
- "description": "集合的当前页。",
- "type": "integer"
- }, "per_page": {
- "default": 10,
- "description": "结果集包含的最大项目数量。",
- "type": "integer"
- }, "search": {
- "description": "将结果限制为匹配字符串的。",
- "type": "string"
- }, "after": {
- "description": "将回应限制在一个给定的ISO8601兼容日期之后发布的文章。",
- "type": "string"
- }, "author": {
- "default": [],
- "description": "限制结果集为指定给特定作者的文章。",
- "type": "array",
- }, "author_exclude": {
- "default": [],
- "description": "确保结果集排除指定给特定作者的文章。",
- "type": "array",
- }, "before": {
- "description": "将回应限制在一个给定的ISO8601兼容日期之前发布的文章。",
- "type": "string"
- }, "exclude": {
- "default": [],
- "description": "确保结果集排除指定ID。",
- "type": "array",
- }, "include": {
- "default": [],
- "description": "将结果集限制到指定ID。",
- "type": "array",
- }, "offset": {
- "description": "将结果集移位特定数量。",
- "type": "integer"
- }, "order": {
- "default": "desc",
- "enum": ["asc", "desc"],
- "description": "设置排序字段升序或降序。",
- "type": "string"
- }, "orderby": {
- "default": "date",
- "enum": ["author", "date", "id", "include", "modified", "parent", "relevance", "slug", "include_slugs", "title"],
- "description": "按对象属性排序集合。",
- "type": "string"
- }, "slug": {
- "description": "限制结果集为有一个或多个特定别名的文章。",
- "type": "array",
- }, "status": {
- "default": "publish",
- "description": "限制结果集为有一个或多个状态的文章。",
- "type": "array",
- "items": {
- "enum": ["publish", "future", "draft", "pending", "private", "trash", "auto-draft", "inherit", "any"],
- "type": "string"
- }
- }, "categories": {
- "default": [],
- "description": "限制结果集为在categories分类法中指定了特定项目的项目。",
- "type": "array",
- }, "categories_exclude": {
- "default": [],
- "description": "限制结果集为在categories分类法中没有指定特定项目的项目。",
- "type": "array",
- }, "tags": {
- "default": [],
- "description": "限制结果集为在tags分类法中指定了特定项目的项目。",
- "type": "array",
- }, "tags_exclude": {
- "default": [],
- "description": "限制结果集为在tags分类法中没有指定特定项目的项目。",
- "type": "array",
- }, "sticky": {
- "description": "限制结果集为置顶项目。",
- "type": "boolean"
- }
示例:如获取第三页
- https://wordpress.crlang.com/wp-json/wp/v2/posts?page=3&per_page=10
POST (需要授权,会修改数据)参数如下:
- "args": {
- "date": {
- "description": "对象的发布时间,站点时区。",
- "type": "string"
- },
- "date_gmt": {
- "description": "对象的发布时间,GMT。",
- "type": "string"
- },
- "slug": {
- "description": "对象类别而言的英数字标识符。",
- "type": "string"
- },
- "status": {
- "enum": ["publish", "future", "draft", "pending", "private"],
- "description": "对象的命名状态。",
- "type": "string"
- },
- "password": {
- "description": "用来保护内容和摘要的密码。",
- "type": "string"
- },
- "title": {
- "description": "对象的标题。",
- "type": "object"
- },
- "content": {
- "description": "对象的内容。",
- "type": "object"
- },
- "author": {
- "description": "对象作者的ID。",
- "type": "integer"
- },
- "excerpt": {
- "description": "对象的摘要。",
- "type": "object"
- },
- "featured_media": {
- "description": "对象的特色媒体ID。",
- "type": "integer"
- },
- "comment_status": {
- "enum": ["open", "closed"],
- "description": "对象是否开放评论。",
- "type": "string"
- },
- "ping_status": {
- "enum": ["open", "closed"],
- "description": "对象是否接受ping。",
- "type": "string"
- },
- "format": {
- "enum": ["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio"],
- "description": "对象的格式。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- },
- "sticky": {
- "description": "对象是否是置顶的。",
- "type": "boolean"
- },
- "template": {
- "description": "用来显示此对象的主题文件。",
- "type": "string"
- },
- "categories": {
- "description": "此对象在category分类法中指定的项目。",
- "type": "array",
- },
- "tags": {
- "description": "此对象在post_tag分类法中指定的项目。",
- "type": "array",
- }
- }
1.2 获取指定ID的文章数据
- https://wordpress.crlang.com/wp-json/wp/v2/posts/123
GET 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "password": {
- "description": "该文章的密码,如文章受密码保护。",
- "type": "string"
- }
- }
示例:如获取加密的文章
- https://wordpress.crlang.com/wp-json/wp/v2/posts/666?password=123
POST 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "date": {
- "description": "对象的发布时间,站点时区。",
- "type": "string"
- },
- "date_gmt": {
- "description": "对象的发布时间,GMT。",
- "type": "string"
- },
- "slug": {
- "description": "对象类别而言的英数字标识符。",
- "type": "string"
- },
- "status": {
- "enum": ["publish", "future", "draft", "pending", "private"],
- "description": "对象的命名状态。",
- "type": "string"
- },
- "password": {
- "description": "用来保护内容和摘要的密码。",
- "type": "string"
- },
- "title": {
- "description": "对象的标题。",
- "type": "object"
- },
- "content": {
- "description": "对象的内容。",
- "type": "object"
- },
- "author": {
- "description": "对象作者的ID。",
- "type": "integer"
- },
- "excerpt": {
- "description": "对象的摘要。",
- "type": "object"
- },
- "featured_media": {
- "description": "对象的特色媒体ID。",
- "type": "integer"
- },
- "comment_status": {
- "enum": ["open", "closed"],
- "description": "对象是否开放评论。",
- "type": "string"
- },
- "ping_status": {
- "enum": ["open", "closed"],
- "description": "对象是否接受ping。",
- "type": "string"
- },
- "format": {
- "enum": ["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio"],
- "description": "对象的格式。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- },
- "sticky": {
- "description": "对象是否是置顶的。",
- "type": "boolean"
- },
- "template": {
- "description": "用来显示此对象的主题文件。",
- "type": "string"
- },
- "categories": {
- "description": "此对象在category分类法中指定的项目。",
- "type": "array",
- },
- "tags": {
- "description": "此对象在post_tag分类法中指定的项目。",
- "type": "array",
- }
- }
DELETE (需要授权,删除动作)参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "force": {
- "default": false,
- "description": "是否绕过回收站并强行删除。",
- "type": "boolean"
- }
- }
1.3 获取指定ID的文章所有的修订版数据
- https://wordpress.crlang.com/wp-json/wp/v2/posts/123/revisions
GET 参数如下:
- "args": {
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
1.4 获取指定ID的文章指定修订ID的数据
- https://wordpress.crlang.com/wp-json/wp/v2/posts/123/revisions/66
GET 参数如下:
- "args": {
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
DELETE 参数如下:
- "args": {
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "force": {
- "default": false,
- "description": "要求为true,因为修订版本不能被移动到回收站。",
- "type": "boolean"
- }
- }
示例:如删除 id 为 123 的第 6 次的修改稿
- DELETE 模式 => https://wordpress.crlang.com/wp-json/wp/v2/posts/123/revisions/6
2 分类
2.1 获取所有分类
- https://wordpress.crlang.com//wp/v2/taxonomies
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "type": {
- "description": "限制结果为关联到特定文章类型的分类法。",
- "type": "string"
- }
- }
2.1 获取指定分类名称的分类信息信息
- https://wordpress.crlang.com//wp/v2/taxonomies/taxonomyName
GET 参数如下:
- "args": {
- "taxonomy": {
- "description": "分类法的英数字标识符。",
- "type": "string"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
3 目录
3.1 获取所有的目录
- https://wordpress.crlang.com/wp-json/wp/v2/categories
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "page": {
- "default": 1,
- "description": "集合的当前页。",
- "type": "integer"
- },
- "per_page": {
- "default": 10,
- "description": "结果集包含的最大项目数量。",
- "type": "integer"
- },
- "search": {
- "description": "将结果限制为匹配字符串的。",
- "type": "string"
- },
- "exclude": {
- "default": [],
- "description": "确保结果集排除指定ID。",
- "type": "array",
- },
- "include": {
- "default": [],
- "description": "将结果集限制到指定ID。",
- "type": "array",
- },
- "order": {
- "default": "asc",
- "enum": ["asc", "desc"],
- "description": "设置排序字段升序或降序。",
- "type": "string"
- },
- "orderby": {
- "default": "name",
- "enum": ["id", "include", "name", "slug", "include_slugs", "term_group", "description", "count"],
- "description": "按项目属性排序集合。",
- "type": "string"
- },
- "hide_empty": {
- "default": false,
- "description": "是否隐藏未被指定到任何文章的项目。",
- "type": "boolean"
- },
- "parent": {
- "description": "限制结果集为指定给特定父项目的项目。",
- "type": "integer"
- },
- "post": {
- "description": "限制结果集为指定给特定文章的项目。",
- "type": "integer"
- },
- "slug": {
- "description": "通过设置一个或多个别名来查询指定标签。",
- "type": "array",
- }
- }
POST 参数如下:
- "args": {
- "description": {
- "description": "项目的HTML描述。",
- "type": "string"
- },
- "name": {
- "required": true,
- "description": "项目的HTML标题。",
- "type": "string"
- },
- "slug": {
- "description": "项目类别而言的英数字标识符。",
- "type": "string"
- },
- "parent": {
- "description": "父项目ID。",
- "type": "integer"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
3.2 获取指定目录ID的目录信息
- https://wordpress.crlang.com/wp-json/wp/v2/categories/123
GET 参数如下:
- "args": {
- "id": {
- "description": "项目的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "id": {
- "description": "项目的唯一标识符。",
- "type": "integer"
- },
- "description": {
- "description": "项目的HTML描述。",
- "type": "string"
- },
- "name": {
- "description": "项目的HTML标题。",
- "type": "string"
- },
- "slug": {
- "description": "项目类别而言的英数字标识符。",
- "type": "string"
- },
- "parent": {
- "description": "父项目ID。",
- "type": "integer"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
DELETE 参数如下:
- "args": {
- "id": {
- "description": "项目的唯一标识符。",
- "type": "integer"
- },
- "force": {
- "default": false,
- "description": "要求为true,因为项目不能被移动到回收站。",
- "type": "boolean"
- }
- }
4 标签
4.1 获取所有的标签
- https://wordpress.crlang.com/wp-json/wp/v2/tags
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "page": {
- "default": 1,
- "description": "集合的当前页。",
- "type": "integer"
- },
- "per_page": {
- "default": 10,
- "description": "结果集包含的最大项目数量。",
- "type": "integer"
- },
- "search": {
- "description": "将结果限制为匹配字符串的。",
- "type": "string"
- },
- "exclude": {
- "default": [],
- "description": "确保结果集排除指定ID。",
- "type": "array",
- },
- "include": {
- "default": [],
- "description": "将结果集限制到指定ID。",
- "type": "array",
- },
- "offset": {
- "description": "将结果集移位特定数量。",
- "type": "integer"
- },
- "order": {
- "default": "asc",
- "enum": ["asc", "desc"],
- "description": "设置排序字段升序或降序。",
- "type": "string"
- },
- "orderby": {
- "default": "name",
- "enum": ["id", "include", "name", "slug", "include_slugs", "term_group", "description", "count"],
- "description": "按项目属性排序集合。",
- "type": "string"
- },
- "hide_empty": {
- "default": false,
- "description": "是否隐藏未被指定到任何文章的项目。",
- "type": "boolean"
- },
- "post": {
- "description": "限制结果集为指定给特定文章的项目。",
- "type": "integer"
- },
- "slug": {
- "description": "通过设置一个或多个别名来查询指定标签。",
- "type": "array",
- }
- }
POST 参数如下:
- "args": {
- "description": {
- "description": "项目的HTML描述。",
- "type": "string"
- },
- "name": {
- "required": true,
- "description": "项目的HTML标题。",
- "type": "string"
- },
- "slug": {
- "description": "项目类别而言的英数字标识符。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
4.2 获取指定标签ID的标签信息
- https://wordpress.crlang.com/wp-json/wp/v2/tags/123
GET 参数如下:
- "args": {
- "id": {
- "description": "项目的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "id": {
- "description": "项目的唯一标识符。",
- "type": "integer"
- },
- "description": {
- "description": "项目的HTML描述。",
- "type": "string"
- },
- "name": {
- "description": "项目的HTML标题。",
- "type": "string"
- },
- "slug": {
- "description": "项目类别而言的英数字标识符。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
DELETE 参数如下:
- "args": {
- "id": {
- "description": "项目的唯一标识符。",
- "type": "integer"
- },
- "force": {
- "default": false,
- "description": "要求为true,因为项目不能被移动到回收站。",
- "type": "boolean"
- }
- }
5 媒体文件
5.1 获取所有的媒体信息
- https://wordpress.crlang.com/wp-json/wp/v2/media
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "page": {
- "default": 1,
- "description": "集合的当前页。",
- "type": "integer"
- },
- "per_page": {
- "default": 10,
- "description": "结果集包含的最大项目数量。",
- "type": "integer"
- },
- "search": {
- "description": "将结果限制为匹配字符串的。",
- "type": "string"
- },
- "after": {
- "description": "将回应限制在一个给定的ISO8601兼容日期之后发布的文章。",
- "type": "string"
- },
- "author": {
- "default": [],
- "description": "限制结果集为指定给特定作者的文章。",
- "type": "array",
- },
- "author_exclude": {
- "default": [],
- "description": "确保结果集排除指定给特定作者的文章。",
- "type": "array",
- },
- "before": {
- "description": "将回应限制在一个给定的ISO8601兼容日期之前发布的文章。",
- "type": "string"
- },
- "exclude": {
- "default": [],
- "description": "确保结果集排除指定ID。",
- "type": "array",
- },
- "include": {
- "default": [],
- "description": "将结果集限制到指定ID。",
- "type": "array",
- },
- "offset": {
- "description": "将结果集移位特定数量。",
- "type": "integer"
- },
- "order": {
- "default": "desc",
- "enum": ["asc", "desc"],
- "description": "设置排序字段升序或降序。",
- "type": "string"
- },
- "orderby": {
- "default": "date",
- "enum": ["author", "date", "id", "include", "modified", "parent", "relevance", "slug", "include_slugs", "title"],
- "description": "按对象属性排序集合。",
- "type": "string"
- },
- "parent": {
- "default": [],
- "description": "限制结果集为一些特定父ID的项目。",
- "type": "array",
- },
- "parent_exclude": {
- "default": [],
- "description": "限制结果集为没有特定父ID的文章。",
- "type": "array",
- },
- "slug": {
- "description": "限制结果集为有一个或多个特定别名的文章。",
- "type": "array",
- },
- "status": {
- "default": "inherit",
- "description": "限制结果集为有一个或多个状态的文章。",
- "type": "array",
- "items": {
- "enum": ["inherit", "private", "trash"],
- "type": "string"
- }
- },
- "media_type": {
- "enum": ["image", "video", "text", "application", "audio"],
- "description": "将结果集限制到某一媒体类型的附件。",
- "type": "string"
- },
- "mime_type": {
- "description": "将结果集限制到某一MIME类型的附件。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "date": {
- "description": "对象的发布时间,站点时区。",
- "type": "string"
- },
- "date_gmt": {
- "description": "对象的发布时间,GMT。",
- "type": "string"
- },
- "slug": {
- "description": "对象类别而言的英数字标识符。",
- "type": "string"
- },
- "status": {
- "enum": ["publish", "future", "draft", "pending", "private"],
- "description": "对象的命名状态。",
- "type": "string"
- },
- "title": {
- "description": "对象的标题。",
- "type": "object"
- },
- "author": {
- "description": "对象作者的ID。",
- "type": "integer"
- },
- "comment_status": {
- "enum": ["open", "closed"],
- "description": "对象是否开放评论。",
- "type": "string"
- },
- "ping_status": {
- "enum": ["open", "closed"],
- "description": "对象是否接受ping。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- },
- "template": {
- "description": "用来显示此对象的主题文件。",
- "type": "string"
- },
- "alt_text": {
- "description": "在附件未能显示时显示的替换文本。",
- "type": "string"
- },
- "caption": {
- "description": "附件说明。",
- "type": "object"
- },
- "description": {
- "description": "附件的描述。",
- "type": "object"
- },
- "post": {
- "description": "附件所属文章的ID。",
- "type": "integer"
- }
- }
5.2 获取指定媒体ID的媒体信息
- https://wordpress.crlang.com/wp-json/wp/v2/wp-content/uploads/123
GET 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "date": {
- "description": "对象的发布时间,站点时区。",
- "type": "string"
- },
- "date_gmt": {
- "description": "对象的发布时间,GMT。",
- "type": "string"
- },
- "slug": {
- "description": "对象类别而言的英数字标识符。",
- "type": "string"
- },
- "status": {
- "enum": ["publish", "future", "draft", "pending", "private"],
- "description": "对象的命名状态。",
- "type": "string"
- },
- "title": {
- "description": "对象的标题。",
- "type": "object"
- },
- "author": {
- "description": "对象作者的ID。",
- "type": "integer"
- },
- "comment_status": {
- "enum": ["open", "closed"],
- "description": "对象是否开放评论。",
- "type": "string"
- },
- "ping_status": {
- "enum": ["open", "closed"],
- "description": "对象是否接受ping。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- },
- "template": {
- "description": "用来显示此对象的主题文件。",
- "type": "string"
- },
- "alt_text": {
- "description": "在附件未能显示时显示的替换文本。",
- "type": "string"
- },
- "caption": {
- "description": "附件说明。",
- "type": "object"
- },
- "description": {
- "description": "附件的描述。",
- "type": "object"
- },
- "post": {
- "description": "附件所属文章的ID。",
- "type": "integer"
- }
- }
DELETE 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "force": {
- "default": false,
- "description": "是否绕过回收站并强行删除。",
- "type": "boolean"
- }
- }
6 页面
6.1 获取所有的页面信息
- https://wordpress.crlang.com/wp-json/wp/v2/pages
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "page": {
- "default": 1,
- "description": "集合的当前页。",
- "type": "integer"
- },
- "per_page": {
- "default": 10,
- "description": "结果集包含的最大项目数量。",
- "type": "integer"
- },
- "search": {
- "description": "将结果限制为匹配字符串的。",
- "type": "string"
- },
- "after": {
- "description": "将回应限制在一个给定的ISO8601兼容日期之后发布的文章。",
- "type": "string"
- },
- "author": {
- "default": [],
- "description": "限制结果集为指定给特定作者的文章。",
- "type": "array",
- },
- "author_exclude": {
- "default": [],
- "description": "确保结果集排除指定给特定作者的文章。",
- "type": "array",
- },
- "before": {
- "description": "将回应限制在一个给定的ISO8601兼容日期之前发布的文章。",
- "type": "string"
- },
- "exclude": {
- "default": [],
- "description": "确保结果集排除指定ID。",
- "type": "array",
- },
- "include": {
- "default": [],
- "description": "将结果集限制到指定ID。",
- "type": "array",
- },
- "menu_order": {
- "description": "限制结果集为有特定menu_order的文章。",
- "type": "integer"
- },
- "offset": {
- "description": "将结果集移位特定数量。",
- "type": "integer"
- },
- "order": {
- "default": "desc",
- "enum": ["asc", "desc"],
- "description": "设置排序字段升序或降序。",
- "type": "string"
- },
- "orderby": {
- "default": "date",
- "enum": ["author", "date", "id", "include", "modified", "parent", "relevance", "slug", "include_slugs", "title", "menu_order"],
- "description": "按对象属性排序集合。",
- "type": "string"
- },
- "parent": {
- "default": [],
- "description": "限制结果集为一些特定父ID的项目。",
- "type": "array",
- },
- "parent_exclude": {
- "default": [],
- "description": "限制结果集为没有特定父ID的文章。",
- "type": "array",
- },
- "slug": {
- "description": "限制结果集为有一个或多个特定别名的文章。",
- "type": "array",
- },
- "status": {
- "default": "publish",
- "description": "限制结果集为有一个或多个状态的文章。",
- "type": "array",
- "items": {
- "enum": ["publish", "future", "draft", "pending", "private", "trash", "auto-draft", "inherit", "any"],
- "type": "string"
- }
- }
- }
POST 参数如下:
- "args": {
- "date": {
- "description": "对象的发布时间,站点时区。",
- "type": "string"
- },
- "date_gmt": {
- "description": "对象的发布时间,GMT。",
- "type": "string"
- },
- "slug": {
- "description": "对象类别而言的英数字标识符。",
- "type": "string"
- },
- "status": {
- "enum": ["publish", "future", "draft", "pending", "private"],
- "description": "对象的命名状态。",
- "type": "string"
- },
- "password": {
- "description": "用来保护内容和摘要的密码。",
- "type": "string"
- },
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "title": {
- "description": "对象的标题。",
- "type": "object"
- },
- "content": {
- "description": "对象的内容。",
- "type": "object"
- },
- "author": {
- "description": "对象作者的ID。",
- "type": "integer"
- },
- "excerpt": {
- "description": "对象的摘要。",
- "type": "object"
- },
- "featured_media": {
- "description": "对象的特色媒体ID。",
- "type": "integer"
- },
- "comment_status": {
- "enum": ["open", "closed"],
- "description": "对象是否开放评论。",
- "type": "string"
- },
- "ping_status": {
- "enum": ["open", "closed"],
- "description": "对象是否接受ping。",
- "type": "string"
- },
- "menu_order": {
- "description": "对象相对于同类型其他对象的排序。",
- "type": "integer"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- },
- "template": {
- "description": "用来显示此对象的主题文件。",
- "type": "string"
- }
- }
6.2 获取指定页面ID的页面信息
- https://wordpress.crlang.com/wp-json/wp/v2/pages/123
GET 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "password": {
- "description": "该文章的密码,如文章受密码保护。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "date": {
- "description": "对象的发布时间,站点时区。",
- "type": "string"
- },
- "date_gmt": {
- "description": "对象的发布时间,GMT。",
- "type": "string"
- },
- "slug": {
- "description": "对象类别而言的英数字标识符。",
- "type": "string"
- },
- "status": {
- "enum": ["publish", "future", "draft", "pending", "private"],
- "description": "对象的命名状态。",
- "type": "string"
- },
- "password": {
- "description": "用来保护内容和摘要的密码。",
- "type": "string"
- },
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "title": {
- "description": "对象的标题。",
- "type": "object"
- },
- "content": {
- "description": "对象的内容。",
- "type": "object"
- },
- "author": {
- "description": "对象作者的ID。",
- "type": "integer"
- },
- "excerpt": {
- "description": "对象的摘要。",
- "type": "object"
- },
- "featured_media": {
- "description": "对象的特色媒体ID。",
- "type": "integer"
- },
- "comment_status": {
- "enum": ["open", "closed"],
- "description": "对象是否开放评论。",
- "type": "string"
- },
- "ping_status": {
- "enum": ["open", "closed"],
- "description": "对象是否接受ping。",
- "type": "string"
- },
- "menu_order": {
- "description": "对象相对于同类型其他对象的排序。",
- "type": "integer"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- },
- "template": {
- "description": "用来显示此对象的主题文件。",
- "type": "string"
- }
- }
6.3 获取指定页面ID的页面信息的所有修订版本
- https://wordpress.crlang.com/wp-json/wp/v2/pages/123/revisions
GET 参数如下:
- "args": {
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
6.4 获取指定页面ID的页面信息的某个ID的修订版本
- https://wordpress.crlang.com/wp-json/wp/v2/pages/123/revisions/66
GET 参数如下:
- "args": {
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
DELETE 参数如下:
- "args": {
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "force": {
- "default": false,
- "description": "要求为true,因为修订版本不能被移动到回收站。",
- "type": "boolean"
- }
- }
7 类型
7.1 获取当前wordpress所有的内容类型
- https://wordpress.crlang.com/wp-json/wp/v2/types
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
7.2 获取指定类型
- https://wordpress.crlang.com/wp-json/wp/v2/types/typeName
GET 参数如下:
- "args": {
- "type": {
- "description": "文章类别的英数字标识符。",
- "type": "string"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
8 评论
8.1 获取所有评论信息
- https://wordpress.crlang.com/wp-json/wp/v2/comments
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "page": {
- "default": 1,
- "description": "集合的当前页。",
- "type": "integer"
- },
- "per_page": {
- "default": 10,
- "description": "结果集包含的最大项目数量。",
- "type": "integer"
- },
- "search": {
- "description": "将结果限制为匹配字符串的。",
- "type": "string"
- },
- "after": {
- "description": "将回应限制在一个给定的ISO8601兼容日期之后发布的评论。",
- "type": "string"
- },
- "author": {
- "description": "将结果集限制在指定给特定用户ID的评论,需要授权。",
- "type": "array",
- },
- "author_exclude": {
- "description": "确保结果集排除指定给特定用户ID的评论,需要授权。",
- "type": "array",
- },
- "author_email": {
- "description": "将结果集限制为指定作者电子邮件地址,需要授权。",
- "type": "string"
- },
- "before": {
- "description": "将回应限制在一个给定的ISO8601兼容日期之前发布的评论。",
- "type": "string"
- },
- "exclude": {
- "default": [],
- "description": "确保结果集排除指定ID。",
- "type": "array",
- },
- "include": {
- "default": [],
- "description": "将结果集限制到指定ID。",
- "type": "array",
- },
- "offset": {
- "description": "将结果集移位特定数量。",
- "type": "integer"
- },
- "order": {
- "default": "desc",
- "enum": ["asc", "desc"],
- "description": "设置排序字段升序或降序。",
- "type": "string"
- },
- "orderby": {
- "default": "date_gmt",
- "enum": ["date", "date_gmt", "id", "include", "post", "parent", "type"],
- "description": "按对象属性排序集合。",
- "type": "string"
- },
- "parent": {
- "default": [],
- "description": "将结果集限制为指定父ID的评论。",
- "type": "array",
- },
- "parent_exclude": {
- "default": [],
- "description": "确保结果集排除指定父ID的评论。",
- "type": "array",
- },
- "post": {
- "default": [],
- "description": "将结果集限制为关联到指定文章ID的评论。",
- "type": "array",
- },
- "status": {
- "default": "approve",
- "description": "将结果集限制为设置特定状态的评论,需要授权。",
- "type": "string"
- },
- "type": {
- "default": "comment",
- "description": "将结果集限制为设置特定类型的评论,需要授权。",
- "type": "string"
- },
- "password": {
- "description": "该文章的密码,如文章受密码保护。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "author": {
- "description": "用户对象的ID,如果作者是用户。",
- "type": "integer"
- },
- "author_email": {
- "description": "对象作者的电子邮件地址。",
- "type": "string"
- },
- "author_ip": {
- "description": "对象作者的IP地址。",
- "type": "string"
- },
- "author_name": {
- "description": "对象作者的显示名。",
- "type": "string"
- },
- "author_url": {
- "description": "对象作者的URL。",
- "type": "string"
- },
- "author_user_agent": {
- "description": "对象作者的用户代理。",
- "type": "string"
- },
- "content": {
- "description": "对象的内容。",
- "type": "object"
- },
- "date": {
- "description": "对象的发布时间,站点时区。",
- "type": "string"
- },
- "date_gmt": {
- "description": "对象的发布时间,GMT。",
- "type": "string"
- },
- "parent": {
- "default": 0,
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "post": {
- "default": 0,
- "description": "关联文章对象的ID。",
- "type": "integer"
- },
- "status": {
- "description": "对象的状态。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
8.2 获取指定评论ID的单条评论信息
- https://wordpress.crlang.com/wp-json/wp/v2/comments/123
GET 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "password": {
- "description": "评论所属文章的密码(如果该文章被密码保护)。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "author": {
- "description": "用户对象的ID,如果作者是用户。",
- "type": "integer"
- },
- "author_email": {
- "description": "对象作者的电子邮件地址。",
- "type": "string"
- },
- "author_ip": {
- "description": "对象作者的IP地址。",
- "type": "string"
- },
- "author_name": {
- "description": "对象作者的显示名。",
- "type": "string"
- },
- "author_url": {
- "description": "对象作者的URL。",
- "type": "string"
- },
- "author_user_agent": {
- "description": "对象作者的用户代理。",
- "type": "string"
- },
- "content": {
- "description": "对象的内容。",
- "type": "object"
- },
- "date": {
- "description": "对象的发布时间,站点时区。",
- "type": "string"
- },
- "date_gmt": {
- "description": "对象的发布时间,GMT。",
- "type": "string"
- },
- "parent": {
- "description": "对象的父对象ID。",
- "type": "integer"
- },
- "post": {
- "description": "关联文章对象的ID。",
- "type": "integer"
- },
- "status": {
- "description": "对象的状态。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
DELETE 参数如下:
- "args": {
- "id": {
- "description": "对象的唯一标识符。",
- "type": "integer"
- },
- "force": {
- "default": false,
- "description": "是否绕过回收站并强行删除。",
- "type": "boolean"
- },
- "password": {
- "description": "评论所属文章的密码(如果该文章被密码保护)。",
- "type": "string"
- }
- }
9 用户
9.1 获取所有的用户信息
- https://wordpress.crlang.com/wp-json/wp/v2/users
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- },
- "page": {
- "default": 1,
- "description": "集合的当前页。",
- "type": "integer"
- },
- "per_page": {
- "default": 10,
- "description": "结果集包含的最大项目数量。",
- "type": "integer"
- },
- "search": {
- "description": "将结果限制为匹配字符串的。",
- "type": "string"
- },
- "exclude": {
- "default": [],
- "description": "确保结果集排除指定ID。",
- "type": "array",
- },
- "include": {
- "default": [],
- "description": "将结果集限制到指定ID。",
- "type": "array",
- },
- "offset": {
- "description": "将结果集移位特定数量。",
- "type": "integer"
- },
- "order": {
- "default": "asc",
- "enum": ["asc", "desc"],
- "description": "设置排序字段升序或降序。",
- "type": "string"
- },
- "orderby": {
- "default": "name",
- "enum": ["id", "include", "name", "registered_date", "slug", "include_slugs", "email", "url"],
- "description": "按对象属性排序集合。",
- "type": "string"
- },
- "slug": {
- "description": "通过一个或多个别名来筛选用户。",
- "type": "array",
- },
- "roles": {
- "description": "限制结果集为匹配至少一个角色的用户,接受csv列表或单个角色。",
- "type": "array",
- }
- }
POST 参数如下:
- "args": {
- "username": {
- "required": true,
- "description": "用户的登录名。",
- "type": "string"
- },
- "name": {
- "description": "用户的显示名。",
- "type": "string"
- },
- "first_name": {
- "description": "用户的名。",
- "type": "string"
- },
- "last_name": {
- "description": "用户的姓。",
- "type": "string"
- },
- "email": {
- "required": true,
- "description": "用户的电子邮件地址。",
- "type": "string"
- },
- "url": {
- "description": "用户的URL。",
- "type": "string"
- },
- "description": {
- "description": "用户的描述。",
- "type": "string"
- },
- "locale": {
- "enum": ["", "en_US", "zh_CN"],
- "description": "用户的语言环境。",
- "type": "string"
- },
- "nickname": {
- "description": "用户的昵称。",
- "type": "string"
- },
- "slug": {
- "description": "用户的英数字标识符。",
- "type": "string"
- },
- "roles": {
- "description": "用户被赋予的角色。",
- "type": "array",
- },
- "password": {
- "required": true,
- "description": "用户的密码(从不被包含)。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
9.2 获取指定用户ID的用户信息
- https://wordpress.crlang.com/wp-json/wp/v2/users/123
GET 参数如下:
- "args": {
- "id": {
- "description": "用户的唯一标识符。",
- "type": "integer"
- },
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "id": {
- "description": "用户的唯一标识符。",
- "type": "integer"
- },
- "username": {
- "description": "用户的登录名。",
- "type": "string"
- },
- "name": {
- "description": "用户的显示名。",
- "type": "string"
- },
- "first_name": {
- "description": "用户的名。",
- "type": "string"
- },
- "last_name": {
- "description": "用户的姓。",
- "type": "string"
- },
- "email": {
- "description": "用户的电子邮件地址。",
- "type": "string"
- },
- "url": {
- "description": "用户的URL。",
- "type": "string"
- },
- "description": {
- "description": "用户的描述。",
- "type": "string"
- },
- "locale": {
- "enum": ["", "en_US", "zh_CN"],
- "description": "用户的语言环境。",
- "type": "string"
- },
- "nickname": {
- "description": "用户的昵称。",
- "type": "string"
- },
- "slug": {
- "description": "用户的英数字标识符。",
- "type": "string"
- },
- "roles": {
- "description": "用户被赋予的角色。",
- "type": "array",
- },
- "password": {
- "description": "用户的密码(从不被包含)。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
DELETE 参数如下:
- "args": {
- "id": {
- "description": "用户的唯一标识符。",
- "type": "integer"
- },
- "force": {
- "default": false,
- "description": "要求为true,因为用户不能被移动到回收站。",
- "type": "boolean"
- },
- "reassign": {
- "required": true,
- "description": "将被删除用户的文章和链接重新指定到此用户ID。",
- "type": "integer"
- }
- }
9.3 获取我的用户信息
- https://wordpress.crlang.com/wp-json/wp/v2/users/me
GET 参数如下:
- "args": {
- "context": {
- "default": "view",
- "enum": ["view", "embed", "edit"],
- "description": "请求提出的范围,用于决定回应包含的字段。",
- "type": "string"
- }
- }
POST 参数如下:
- "args": {
- "username": {
- "description": "用户的登录名。",
- "type": "string"
- },
- "name": {
- "description": "用户的显示名。",
- "type": "string"
- },
- "first_name": {
- "description": "用户的名。",
- "type": "string"
- },
- "last_name": {
- "description": "用户的姓。",
- "type": "string"
- },
- "email": {
- "description": "用户的电子邮件地址。",
- "type": "string"
- },
- "url": {
- "description": "用户的URL。",
- "type": "string"
- },
- "description": {
- "description": "用户的描述。",
- "type": "string"
- },
- "locale": {
- "enum": ["", "en_US", "zh_CN"],
- "description": "用户的语言环境。",
- "type": "string"
- },
- "nickname": {
- "description": "用户的昵称。",
- "type": "string"
- },
- "slug": {
- "description": "用户的英数字标识符。",
- "type": "string"
- },
- "roles": {
- "description": "用户被赋予的角色。",
- "type": "array",
- },
- "password": {
- "description": "用户的密码(从不被包含)。",
- "type": "string"
- },
- "meta": {
- "description": "元字段。",
- "type": "object"
- }
- }
DELETE 参数如下:
- "args": {
- "force": {
- "default": false,
- "description": "要求为true,因为用户不能被移动到回收站。",
- "type": "boolean"
- },
- "reassign": {
- "required": true,
- "description": "将被删除用户的文章和链接重新指定到此用户ID。",
- "type": "integer"
- }
- }
10 设置
10.1 获取网站后所有设置项
- https://wordpress.crlang.com//wp/v2/settings
POST 参数如下:
- "args": {
- "title": {
- "description": "站点标题。",
- "type": "string"
- },
- "description": {
- "description": "站点副标题。",
- "type": "string"
- },
- "url": {
- "description": "站点URL。",
- "type": "string"
- },
- "email": {
- "description": "此地址被用作管理用途,如新用户通知。",
- "type": "string"
- },
- "timezone": {
- "description": "和您在同一个时区的城市。",
- "type": "string"
- },
- "date_format": {
- "description": "对所有日期字符串适用的日期格式。",
- "type": "string"
- },
- "time_format": {
- "description": "对所有时间字符串适用的时间格式。",
- "type": "string"
- },
- "start_of_week": {
- "description": "一周从周几开始。",
- "type": "integer"
- },
- "language": {
- "description": "WordPress地区代码。",
- "type": "string"
- },
- "use_smilies": {
- "description": "将表情符号如:-)和:-P转换为图片显示。",
- "type": "boolean"
- },
- "default_category": {
- "description": "默认文章类别。",
- "type": "integer"
- },
- "default_post_format": {
- "description": "默认文章格式。",
- "type": "string"
- },
- "posts_per_page": {
- "description": "最多显示的博客页面数量。",
- "type": "integer"
- },
- "default_ping_status": {
- "enum": ["open", "closed"],
- "description": "允许其他博客发送链接通知(pingback和trackback)到新文章。",
- "type": "string"
- },
- "default_comment_status": {
- "enum": ["open", "closed"],
- "description": "允许他人在新文章上发表评论。",
- "type": "string"
- }
- }
备注:一般 context
是指直接返回数据,不需要额外参数;
完毕!