
hexo-info-api is a Hexo plugin I wrote to export blog data as JSON. Hexo still generates the static website, while another page or tool can read posts, categories, and tags without extracting them from HTML.
Available data
The built-in modules cover site information, post count, post lists, categories, tags, the latest post, and the latest five posts. Posts can also be selected by category, tag, ID, or path.
List entries include the title, date, description, categories, tags, and original link. Single-post output adds the body. The description uses the post's description field when present and otherwise falls back to excerpt.
A post-count response looks like this:
{
"type": "getPostCount",
"data": {
"count": 0
}
}Selecting modules
After installation, the enabled outputs are selected in Hexo's _config.yml:
hexo_info_api:
allowOrigin: "*"
enable:
- getInfo
- getPostCount
- getPosts
- getCategories
- getTags
- getLatestPost
disable_default_api: falseThe default /api/ entry lists the enabled endpoints. disable_default_api turns that entry off. Each endpoint has a module under lib/api, and only selected modules are loaded.

Generation and local serving
The implementation uses Hexo generators. A module reads Hexo's content and returns output paths and JSON strings for the site build. Queries by post path are generated as paths for the posts available at build time.
For Hexo Server, a server_middleware filter sets the JSON content type and CORS header under /api/, using allowOrigin from the configuration. Static data generation and local-server headers are handled separately.
I published the plugin on npm, documented the response structures in the repository wiki, and wrote about its development.
npm · Source and API documentation · Development notes
