Skip to content

API Endpoints ​

Base URL ​

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

แทนที่ :version ด้วยเวอร์ชันที่รองรับด้านล่าง

เวอร์ชัน ​

เวอร์ชัน
สถานะ
v2
ปัจจุบันและดูแลต่อเนื่อง

TIP

แนะนำให้ตั้งค่า User-Agent header แบบกำหนดเองทุกครั้งที่ส่งคำขอ ดูรูปแบบที่แนะนำได้ที่ เอกสาร User-Agent

Endpoints ​

GET /endpoints ​

ส่งคืนหมวดหมู่ทั้งหมดที่มีใน API พร้อมรูปแบบไฟล์ของแต่ละหมวด

ตัวอย่าง ​

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

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

TIP

ควรใช้ endpoint นี้เพื่อดึงรายชื่อหมวดหมู่ที่รองรับแบบไดนามิก แทนการ hardcode ไว้ในโค้ด


GET /:category ​

ส่งคืนรูปภาพหรือ GIF แบบสุ่มจากหมวดหมู่ที่ระบุ พร้อม metadata

Query Parameters ​

ชื่อชนิดข้อมูลจำเป็นคำอธิบาย
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 โดยใช้ metadata เช่น ชื่อนักวาด หรือชื่อเรื่องต้นฉบับ

Query Parameters ​

ชื่อชนิดข้อมูลจำเป็นคำอธิบาย
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 ​

ดึงไฟล์รูปภาพหรือ GIF ที่ระบุโดยตรง

Path Parameters ​

ชื่อคำอธิบาย
categoryชื่อหมวดหมู่
filenameชื่อไฟล์ (UUID)
formatรูปแบบไฟล์ (png, gif)

INFO

metadata ของ endpoint นี้จะถูกส่งกลับมาในรูปแบบ HTTP response headers ที่เข้ารหัส URL (URL-encoded)

header ที่มีให้ใช้งาน:

  • anime_name
  • artist_name
  • artist_href
  • source_url

ตัวอย่าง ​

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

การตอบกลับ: ข้อมูลไบนารีของรูปภาพหรือ GIF