English

ACG API

随机图片接口 - JSON 响应 & 客户端跳转

快速开始

获取随机图片 JSON(真正随机,每次调用返回不同结果):

curl https://acg-api.pages.dev/api/random

获取随机图片 JSON(静态文件,结果固定):

curl https://username.github.io/acg-api/api/random.json

直接跳转到随机图片:

https://username.github.io/acg-api/img/random.html

API 端点

GET /api/random.json
返回随机图片 JSON。
GET /api/{category}.json
返回指定分类的随机图片 JSON。
GET /api/categories.json
返回所有分类及图片数量。
GET /img/random.html
浏览器直接跳转到随机图片。
GET /img/{category}.html
浏览器跳转到指定分类的随机图片。

分类统计

加载中...

在线测试

使用示例

# Cloudflare Pages - 真正随机(每次返回不同结果)
curl https://acg-api.pages.dev/api/random
curl https://acg-api.pages.dev/api/random?size=5
curl https://acg-api.pages.dev/api/anime
curl https://acg-api.pages.dev/api/categories

# GitHub Pages - 静态文件(结果固定)
curl https://username.github.io/acg-api/api/random.json
curl https://username.github.io/acg-api/api/anime.json
curl https://username.github.io/acg-api/api/categories.json

# 浏览器批量获取(需执行 JavaScript)
https://username.github.io/acg-api/?api=random&size=5
https://username.github.io/acg-api/?api=random&category=anime&size=3

添加图片

1. 将图片放入 images/分类名/ 目录

2. Push 到 master 分支

3. GitHub Actions 自动更新索引