PHPackages                             moefront/typecho-plugin-restful - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. moefront/typecho-plugin-restful

ActivePlugin[API Development](/categories/api)

moefront/typecho-plugin-restful
===============================

Yet another awesome Typecho plugin to make your blog RESTful.

1.0.1(1y ago)1063828[8 issues](https://github.com/moefront/typecho-plugin-Restful/issues)[2 PRs](https://github.com/moefront/typecho-plugin-Restful/pulls)MITPHPPHP &gt;=5.3.0CI failing

Since Jan 29Pushed 7mo ago4 watchersCompare

[ Source](https://github.com/moefront/typecho-plugin-Restful)[ Packagist](https://packagist.org/packages/moefront/typecho-plugin-restful)[ Docs](https://github.com/moefront/typecho-plugin-Restful)[ RSS](/packages/moefront-typecho-plugin-restful/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (6)Versions (6)Used By (0)

Typecho Restful 插件
==================

[](#typecho-restful-插件)

[![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)[![Version](https://camo.githubusercontent.com/dc813d6e1319f69fb1922b6d22fa69509cabb90fc670cbc846d82a45a2b4884b/68747470733a2f2f62616467652e667572792e696f2f70682f6d6f6566726f6e742532467479706563686f2d706c7567696e2d7265737466756c2e737667)](https://packagist.org/packages/moefront/typecho-plugin-restful)[![styled with prettier](https://camo.githubusercontent.com/7c31269a4fab27bd4b327813e7a459cf7a76da0b0b009254bf949a20889d2b6c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c65645f776974682d70726574746965722d6666363962342e737667)](https://github.com/prettier/prettier)[![built by](https://camo.githubusercontent.com/6b88619030096da897c6967f4e9ae5428e09ac4fa5ecc3fa78e638ceae452d27/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c745f62792d4d6f6546726f6e742d6666363962342e737667)](https://camo.githubusercontent.com/6b88619030096da897c6967f4e9ae5428e09ac4fa5ecc3fa78e638ceae452d27/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c745f62792d4d6f6546726f6e742d6666363962342e737667)

这是一个将 Typecho 博客 RESTful 化的插件。启用此插件，你可以通过请求 API 向站点请求或写入信息（获取文章内容、获取评论、添加评论等）。

**不兼容Typecho1.2以前版本**

食用方法
----

[](#食用方法)

### 常规

[](#常规)

下载插件并解压，将解压后的目录重命名为 `Restful` (区分大小写)，然后到后台插件管理页面启用并设置即可。

### 使用 Composer 安装

[](#使用-composer-安装)

```
cd /path/to/typecho/usr/plugins
composer create-project moefront/typecho-plugin-restful Restful --prefer-dist --stability=dev
chown www:www -R Restful
```

API
---

[](#api)

下面假设您的站点已经开启了地址重写（伪静态）；如果没有的话，那么需要在下文列出的请求的 URI 前加上 `/index.php`，例如： `/api/posts` =&gt; `/index.php/api/posts`.

### 文章列表

[](#文章列表)

`GET /api/posts`

参数类型描述pageint当前页可选pageSizeint分页数可选filterTypestringcategory 或 tag 或 search可选filterSlugstring分类名或标签名或搜索关键字可选showContentbool是否显示文章具体内容可选showDigeststring指定是否显示文章摘要及显示摘要的类型可选limitint当 showDigest 的类型为 excerpt 时，指定截断的字数可选PS： `showDigest` 有两个可选的值，分别为 `more` 和 `excerpt`. 当选用 `more` 模式时，插件将返回文章中 `\`标签前的内容解析后的 HTML；选用 `excerpt` 模式时，插件将对解析后的文章过滤 HTML 标签后，返回前 `limit` 个字符。默认 `limit`的值为 200.

### 页面列表

[](#页面列表)

`GET /api/pages`

### 分类列表

[](#分类列表)

`GET /api/categories`

### 标签列表

[](#标签列表)

`GET /api/tags`

### 文章/页面详情

[](#文章页面详情)

`GET /api/post`

参数类型描述cidint文章/页面 ID二选一slugstring文章/页面别名二选一### 评论列表

[](#评论列表)

`GET /api/comments`

参数类型描述pageint当前页可选pageSizeint分页数可选orderstring评论显示顺序(asc/desc)可选cidint文章 ID二选一slugstring文章别名二选一PS: 如果带上 Cookie 请求，会显示当前 Cookie 记住的用户所发布的待审核的评论。

### 最近评论

[](#最近评论)

`GET /api/recentComments`

参数类型描述sizeint最近评论的条数，默认为 9可选### 发表评论

[](#发表评论)

`POST /api/comment`

参数类型描述cidint文章 ID二选一slugstring文章别名二选一parentint父级评论 ID可选textstring评论内容必须mailstring邮箱必须urlstringURL可选tokenstring文章详情的csrfToken必须authorstring作者必须authorIdint作者Id可选ownerIdint所有者Id可选PS：此处`Content-Type`为`application/json`, 也就是说你应当以 JSON 格式提交数据。

PS2: uid 可以在 Cookie 中找到（形如 `hash__typecho_uid` 和 `hash__typecho_authCode` 的内容）。如果直接带上 Cookie 请求此 API 则不再需要带上 `authorId` 参数。请求时需要带上合法的 User-Agent.

### 设置项

[](#设置项)

`GET /api/settings`

### 用户信息

[](#用户信息)

`GET /api/users`

参数类型描述uidint用户 ID可选namestring用户的用户名或昵称可选### 归档

[](#归档)

`GET /api/archives`

PS：默认按从新到旧 (desc) 顺序排列文章。

参数类型描述orderstring归档的排序方式 (asc / desc)可选showContentbool是否显示文章内容可选showDigeststring指定是否显示文章摘要及显示摘要的类型可选limitint当 showDigest 的类型为 excerpt 时，指定截断的字数可选PS: `showDigest` 和 `limit` 参数的使用参见 `/api/posts` 部分。

### 用户列表

[](#用户列表)

`GET /api/userList`

### 发表文章/更新

[](#发表文章更新)

`GET /api/postArticle`

PS: 根据标题或别名新增/更新文章。

参数类型描述titlestring标题必须textstring内容必须authorIdint作者id必须slugstring别名（优先根据别名更新文章）可选midstring分类/标签id(多个用逗号分隔)可选PS: mid是因为typecho分类跟标签是同一个表。

### 新增分类/标签

[](#新增分类标签)

`GET /api/addMetas`

参数类型描述namestring名称必须typestring类型（category/tag）必须slugstring别名可选其它
--

[](#其它)

### 自定义 URI 前缀

[](#自定义-uri-前缀)

默认情况下 Restful 插件会占用 `/api/*` 用于不同的接口。如果该 URI 有其它用途，或与其它插件冲突，或者由于某些不可描述的原因用户不希望暴露该接口，可以选择通过修改 `config.inc.php` 自定义前缀。

例如，在 `config.inc.php` 文件中加入下列内容：

```
define('__TYPECHO_RESTFUL_PREFIX__', '/rest/');
```

**重新启用插件**，此时你可以通过 `/rest/*` 访问相关 API.

License
-------

[](#license)

`typecho-plugin-restful` is MIT licensed.

Since it is a derivative of Typecho which is GPLv2 licensed, you may also need to observe GPLv2 when you are redistributing this plugin.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance55

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 53.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~732 days

Total

2

Last Release

378d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd71f08cd141186716bc7747100d69c5bf6195a62f6ed34e4959d383ff74c6f8?d=identicon)[kokororin](/maintainers/kokororin)

![](https://www.gravatar.com/avatar/2ebfc0b3db94c6ef495381a09d2bb41a7257e520ba2947834608c0e1787a4a7b?d=identicon)[kirainmoe](/maintainers/kirainmoe)

---

Top Contributors

[![kirainmoe](https://avatars.githubusercontent.com/u/12712012?v=4)](https://github.com/kirainmoe "kirainmoe (47 commits)")[![kokororin](https://avatars.githubusercontent.com/u/10093992?v=4)](https://github.com/kokororin "kokororin (38 commits)")[![aprilies](https://avatars.githubusercontent.com/u/5691730?v=4)](https://github.com/aprilies "aprilies (1 commits)")[![Chen2226](https://avatars.githubusercontent.com/u/77887862?v=4)](https://github.com/Chen2226 "Chen2226 (1 commits)")[![YuiNijika](https://avatars.githubusercontent.com/u/165134730?v=4)](https://github.com/YuiNijika "YuiNijika (1 commits)")

---

Tags

restfultypechotypecho-plugintypechotypecho plugin

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/moefront-typecho-plugin-restful/health.svg)

```
[![Health](https://phpackages.com/badges/moefront-typecho-plugin-restful/health.svg)](https://phpackages.com/packages/moefront-typecho-plugin-restful)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
