Skip to content

API 端点 ​

基础 URL ​

https://nekos.best/api/:version

将 :version 替换为下方列出的受支持版本之一。

版本 ​

版本
状态
v2
当前版本 · 维护中

TIP

我们建议在发起请求时设置自定义 User-Agent 请求头。推荐格式请参阅 User-Agent 文档。

端点 ​

GET /endpoints ​

返回所有可用的 API 分类及其对应的文件格式。

示例 ​

https://nekos.best/api/v2/endpoints

json
{
  "neko": { "format": "png" },
  "...": {},
  "wink": { "format": "gif" }
}

TIP

建议使用此端点动态获取支持的分类,而不是在代码中硬编码。


GET /:category ​

从指定分类中返回随机图片或 GIF 及其元数据。

查询参数 ​

参数名类型必填说明
amountnumber否返回的结果数量(1 ≤ X ≤ 20)

未指定时默认为 1。

示例(单个结果) ​

https://nekos.best/api/v2/neko

json
{
  "results": [
    {
      "artist_name": "John Doe",
      "artist_href": "https://www.example.com/en/users/1234567",
      "source_url": "https://www.example.com/en/artworks/1234567",
      "url": "https://nekos.best/api/v2/neko/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png",
      "dimensions": {
        "width": 420,
        "height": 690
      }
    }
  ]
}

示例(多个结果) ​

https://nekos.best/api/v2/hug?amount=2

json
{
  "results": [
    {
      "anime_name": "Generic Anime Name",
      "url": "https://nekos.best/api/v2/hug/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.gif",
      "dimensions": {
        "width": 420,
        "height": 690
      }
    },
    {
      "anime_name": "Generic Anime Name",
      "url": "https://nekos.best/api/v2/hug/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.gif",
      "dimensions": {
        "width": 420,
        "height": 690
      }
    }
  ]
}

根据画师名称或作品标题等元数据搜索图片或 GIF。

查询参数 ​

参数名类型必填说明
querystring是搜索关键词
typeenum是1 = 图片,2 = GIF
categorystring否将结果限定在指定分类内
amountnumber否返回的结果数量(1 ≤ X ≤ 20)

示例(图片搜索) ​

https://nekos.best/api/v2/search?query=John&type=1

json
{
  "results": [
    {
      "artist_name": "John Doe",
      "artist_href": "https://www.example.com/en/users/1234567",
      "source_url": "https://www.example.com/en/artworks/1234567",
      "url": "https://nekos.best/api/v2/neko/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png",
      "dimensions": {
        "width": 420,
        "height": 690
      }
    }
  ]
}

示例(按分类搜索 GIF) ​

https://nekos.best/api/v2/search?query=Generic&type=2&category=pat&amount=2

json
{
  "results": [
    {
      "anime_name": "Generic Anime Name",
      "url": "https://nekos.best/api/v2/hug/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.gif",
      "dimensions": {
        "width": 420,
        "height": 690
      }
    },
    {
      "anime_name": "Generic Anime Name",
      "url": "https://nekos.best/api/v2/hug/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.gif",
      "dimensions": {
        "width": 420,
        "height": 690
      }
    }
  ]
}

GET /:category/:filename.:format ​

直接获取指定的资源文件。

路径参数 ​

参数名说明
category分类名称
filename资源文件名(UUID)
format文件格式(png、gif)

INFO

该端点的元数据通过 URL 编码的 HTTP 响应头返回。

可用响应头:

  • anime_name
  • artist_name
  • artist_href
  • source_url

示例 ​

https://nekos.best/api/v2/hug/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.gif

响应: 图片或 GIF 的二进制数据