{"id":22347889,"url":"https://github.com/moefront/typecho-plugin-restful","last_synced_at":"2025-07-30T04:33:29.437Z","repository":{"id":41094943,"uuid":"117778712","full_name":"moefront/typecho-plugin-Restful","owner":"moefront","description":"Yet another awesome Typecho plugin to make your blog RESTful.","archived":false,"fork":false,"pushed_at":"2025-05-19T05:21:54.000Z","size":112,"stargazers_count":89,"open_issues_count":7,"forks_count":26,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-05T17:34:33.602Z","etag":null,"topics":["restful","typecho","typecho-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moefront.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-17T03:30:30.000Z","updated_at":"2025-07-02T23:51:46.000Z","dependencies_parsed_at":"2024-12-04T10:11:42.734Z","dependency_job_id":"dbbbce03-c620-4399-a23a-8e1cf06a731f","html_url":"https://github.com/moefront/typecho-plugin-Restful","commit_stats":{"total_commits":56,"total_committers":3,"mean_commits":"18.666666666666668","dds":0.4642857142857143,"last_synced_commit":"feb4dab263cfdd206d21477f4c32409b874c0d5d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/moefront/typecho-plugin-Restful","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moefront%2Ftypecho-plugin-Restful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moefront%2Ftypecho-plugin-Restful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moefront%2Ftypecho-plugin-Restful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moefront%2Ftypecho-plugin-Restful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moefront","download_url":"https://codeload.github.com/moefront/typecho-plugin-Restful/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moefront%2Ftypecho-plugin-Restful/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267809698,"owners_count":24147516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["restful","typecho","typecho-plugin"],"created_at":"2024-12-04T10:11:38.648Z","updated_at":"2025-07-30T04:33:29.421Z","avatar_url":"https://github.com/moefront.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typecho Restful 插件\n\n[![Unit Test](https://github.com/moefront/typecho-plugin-Restful/actions/workflows/test.yml/badge.svg)](https://github.com/moefront/typecho-plugin-Restful/actions/workflows/test.yml)\n[![Version](https://badge.fury.io/ph/moefront%2Ftypecho-plugin-restful.svg)](https://packagist.org/packages/moefront/typecho-plugin-restful)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n![built by](https://img.shields.io/badge/built_by-MoeFront-ff69b4.svg)\n\n这是一个将 Typecho 博客 RESTful 化的插件。启用此插件，你可以通过请求 API 向站点请求或写入信息（获取文章内容、获取评论、添加评论等）。\n\n**\u003ctext style=\"font-size: 1.2rem\"\u003e不兼容Typecho1.2以前版本\u003c/text\u003e**\n\n## 食用方法\n\n### 常规\n\n下载插件并解压，将解压后的目录重命名为 `Restful` (区分大小写)，然后到后台插件管理页面启用并设置即可。\n\n### 使用 Composer 安装\n\n```bash\ncd /path/to/typecho/usr/plugins\ncomposer create-project moefront/typecho-plugin-restful Restful --prefer-dist --stability=dev\nchown www:www -R Restful\n```\n\n## API\n\n下面假设您的站点已经开启了地址重写（伪静态）；如果没有的话，那么需要在下文列出的请求的 URI 前加上 `/index.php`，例如：\n`/api/posts` =\u003e `/index.php/api/posts`.\n\n### 文章列表\n\n`GET /api/posts`\n\n| 参数          | 类型     | 描述                                  |    |\n|-------------|--------|-------------------------------------|----|\n| page        | int    | 当前页                                 | 可选 |\n| pageSize    | int    | 分页数                                 | 可选 |\n| filterType  | string | category 或 tag 或 search             | 可选 |\n| filterSlug  | string | 分类名或标签名或搜索关键字                       | 可选 |\n| showContent | bool   | 是否显示文章具体内容                          | 可选 |\n| showDigest  | string | 指定是否显示文章摘要及显示摘要的类型                  | 可选 |\n| limit       | int    | 当 showDigest 的类型为 excerpt 时，指定截断的字数 | 可选 |\n\nPS： `showDigest` 有两个可选的值，分别为 `more` 和 `excerpt`. 当选用 `more` 模式时，插件将返回文章中 `\u003c!--more--\u003e`\n标签前的内容解析后的 HTML；选用 `excerpt` 模式时，插件将对解析后的文章过滤 HTML 标签后，返回前 `limit` 个字符。默认 `limit`\n的值为 200.\n\n### 页面列表\n\n`GET /api/pages`\n\n### 分类列表\n\n`GET /api/categories`\n\n### 标签列表\n\n`GET /api/tags`\n\n### 文章/页面详情\n\n`GET /api/post`\n\n| 参数   | 类型     | 描述       |     |\n|------|--------|----------|-----|\n| cid  | int    | 文章/页面 ID | 二选一 |\n| slug | string | 文章/页面别名  | 二选一 |\n\n### 评论列表\n\n`GET /api/comments`\n\n| 参数       | 类型     | 描述               |     |\n|----------|--------|------------------|-----|\n| page     | int    | 当前页              | 可选  |\n| pageSize | int    | 分页数              | 可选  |\n| order    | string | 评论显示顺序(asc/desc) | 可选  |\n| cid      | int    | 文章 ID            | 二选一 |\n| slug     | string | 文章别名             | 二选一 |\n\nPS: 如果带上 Cookie 请求，会显示当前 Cookie 记住的用户所发布的待审核的评论。\n\n### 最近评论\n\n`GET /api/recentComments`\n\n| 参数   | 类型  | 描述            |    |\n|------|-----|---------------|----|\n| size | int | 最近评论的条数，默认为 9 | 可选 |\n\n### 发表评论\n\n`POST /api/comment`\n\n| 参数       | 类型     | 描述             |     |\n|----------|--------|----------------|-----|\n| cid      | int    | 文章 ID          | 二选一 |\n| slug     | string | 文章别名           | 二选一 |\n| parent   | int    | 父级评论 ID        | 可选  |\n| text     | string | 评论内容           | 必须  |\n| mail     | string | 邮箱             | 必须  |\n| url      | string | URL            | 可选  |\n| token    | string | 文章详情的csrfToken | 必须  |\n| author   | string | 作者             | 必须  |\n| authorId | int    | 作者Id           | 可选  |\n| ownerId  | int    | 所有者Id          | 可选  |\n\nPS：此处`Content-Type`为`application/json`, 也就是说你应当以 JSON 格式提交数据。\n\nPS2: uid 可以在 Cookie 中找到（形如 `hash__typecho_uid` 和 `hash__typecho_authCode` 的内容）。如果直接带上\nCookie 请求此 API 则不再需要带上 `authorId` 参数。请求时需要带上合法的 User-Agent.\n\n### 设置项\n\n`GET /api/settings`\n\n### 用户信息\n\n`GET /api/users`\n\n| 参数   | 类型     | 描述        |    |\n|------|--------|-----------|----|\n| uid  | int    | 用户 ID     | 可选 |\n| name | string | 用户的用户名或昵称 | 可选 |\n\n### 归档\n\n`GET /api/archives`\n\nPS：默认按从新到旧 (desc) 顺序排列文章。\n\n| 参数          | 类型     | 描述                                  |    |\n|-------------|--------|-------------------------------------|----|\n| order       | string | 归档的排序方式 (asc / desc)                | 可选 |\n| showContent | bool   | 是否显示文章内容                            | 可选 |\n| showDigest  | string | 指定是否显示文章摘要及显示摘要的类型                  | 可选 |\n| limit       | int    | 当 showDigest 的类型为 excerpt 时，指定截断的字数 | 可选 |\n\nPS: `showDigest` 和 `limit` 参数的使用参见 `/api/posts` 部分。\n\n### 用户列表\n\n`GET /api/userList`\n\n### 发表文章/更新\n\n`GET /api/postArticle`\n\nPS: 根据标题或别名新增/更新文章。\n\n| 参数       | 类型     | 描述               |    |\n|----------|--------|------------------|----|\n| title    | string | 标题               | 必须 |\n| text     | string | 内容               | 必须 |\n| authorId | int    | 作者id             | 必须 |\n| slug     | string | 别名（优先根据别名更新文章）   | 可选 |\n| mid      | string | 分类/标签id(多个用逗号分隔) | 可选 |\n\nPS: mid是因为typecho分类跟标签是同一个表。\n\n### 新增分类/标签\n\n`GET /api/addMetas`\n\n| 参数   | 类型     | 描述               |    |\n|------|--------|------------------|----|\n| name | string | 名称               | 必须 |\n| type | string | 类型（category/tag） | 必须 |\n| slug | string | 别名               | 可选 |\n\n## 其它\n\n### 自定义 URI 前缀\n\n默认情况下 Restful 插件会占用 `/api/*` 用于不同的接口。如果该 URI 有其它用途，或与其它插件冲突，或者由于某些不可描述的原因用户不希望暴露该接口，可以选择通过修改\n`config.inc.php` 自定义前缀。\n\n例如，在 `config.inc.php` 文件中加入下列内容：\n\n```php\ndefine('__TYPECHO_RESTFUL_PREFIX__', '/rest/');\n```\n\n**重新启用插件**，此时你可以通过 `/rest/*` 访问相关 API.\n\n## License\n\n`typecho-plugin-restful` is MIT licensed.\n\nSince it is a derivative of Typecho which is GPLv2 licensed, you may also need to observe GPLv2 when you are\nredistributing this plugin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoefront%2Ftypecho-plugin-restful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoefront%2Ftypecho-plugin-restful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoefront%2Ftypecho-plugin-restful/lists"}