随机猪猪
GitHub
API

随机猪猪 API

一行代码获取随机猪猪图片,支持批量获取和直接跳转。

接口端点

GET/api/random-pig

返回一张随机猪图的 JSON 信息

响应示例

JSON
// 响应示例
{
  "filename": "猪反转.jpg",
  "title": "猪反转",
  "url": "https://raw.githubusercontent.com/..."
}

参数

参数类型说明
countnumber (1-20)返回多张图片,默认 1
redirectboolean为 true 时直接 302 跳转到图片(仅单张)

使用示例

获取单张图片

GET /api/random-pig

批量获取 5 张

GET /api/random-pig?count=5

直接跳转到图片

GET /api/random-pig?redirect=true

快速开始

在 HTML 中使用

HTML
<img
  src="/api/random-pig?redirect=true"
  alt="随机猪图"
/>