/health GET

https://karsenal-api.netlify.app/.netlify/functions/health
检查土豆是否成熟。 Check if the service is alive.
响应格式Response Format
{
  "status": "ok",
  "timestamp": "2026-09-25T11:30:00.000Z",
  "uptime": 12.34
}
示例Example
curl https://karsenal-api.netlify.app/.netlify/functions/health

/generate POST

https://karsenal-api.netlify.app/.netlify/functions/generate
生成 KARDS 卡组图片。 Generate KARDS deck images.
Content-Type: application/json
请求体Request Body
基础Base
参数Item 类型Type 默认值Default 描述Description
deckCodestring-必填,KARDS 卡组代码Required, KARDS deck code
colsnumber10每行卡牌数量Number of cards per row
scalenumber50缩放比例(25–100)Image scale (25–100)
langstringzh-Hans语言代码Language code
bgColorstringtransparent背景颜色(十六进制颜色码)Background color (hex)
附件Attachment
参数Item 类型Type 默认值Default 描述Description
foldEnabledbooleanfalse折叠重复卡牌Fold same cards
addStatsCardbooleantrue统计卡Statistical card
statsTitlestring卡组统计统计卡标题Statistical card title
qrEnabledbooleanfalse二维码卡QR code card
qrTitlestring卡组二维码二维码卡标题QR code card title
hqstring-总部 cardId(如 moscow)HQ cardId (e.g. moscow)
statsChartTogglebooleanfalse额外统计图Additional statistical chart
高级Advanced
参数Item 类型Type 默认值Default 描述Description
versionstringDEFAULT_VERSION卡牌版本Card version
spacingXnumber0水平间距Horizontal spacing
spacingYnumber0垂直间距Vertical spacing
emptySlotsarray[]空位索引数组Vacancy index array
cardOverridesobject{}单卡覆盖配置Single-card override settings
cardOverrides 格式Format
{
  "cardId": {
    "version": "v52",
    "cost": 3,
    "star": true
  }
}
语言代码Language Codes
代码Code 语言Language
zh-Hans简体中文
zh-Hant繁體中文
en-ENEnglish
fr-FRFrançais
de-DEDeutsch
pl-PLPolski
pt-BRPortuguês
ru-RUPусский
it-ITItaliano
es-ESEspañol
ko-KR한국어
ja-JP日本語
响应格式Response Format
{
  "mainImage": "data:image/png;base64,...",
  "statsChart": "data:image/png;base64,..."
}
字段Field 描述Description
mainImage卡组图片(Base64)Deck image (Base64)
statsChart额外统计图(仅当 statsChartToggle: true 时返回)Additional statistical chart (returned only if statsChartToggle: true)
错误响应Error Response
{
  "error": "错误描述 Error Description"
}
示例Examples
cURL
curl -X POST https://karsenal-api.netlify.app/.netlify/functions/generate \
  -H "Content-Type: application/json" \
  -d '{
    "deckCode": "%%5a|jvpy;j3xAyc;czydj1bPmI;ggbKpEy6",
    "cols": 8,
    "lang": "zh-Hans"
  }'
JavaScript (Node.js)
import fs from 'fs';

const response = await fetch('https://karsenal-api.netlify.app/.netlify/functions/generate', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    deckCode: '%%5a|jvpy;j3xAyc;czydj1bPmI;ggbKpEy6',
    cols: 8,
    lang: 'zh-Hans'
  })
});

const data = await response.json();
const base64Data = data.mainImage.replace(/^data:image\/png;base64,/, '');
fs.writeFileSync('deck.png', Buffer.from(base64Data, 'base64'));
Python
import requests
import base64

response = requests.post('https://karsenal-api.netlify.app/.netlify/functions/generate', json={
    'deckCode': '%%5a|jvpy;j3xAyc;czydj1bPmI;ggbKpEy6',
    'cols': 8,
    'lang': 'zh-Hans'
})

data = response.json()
base64_data = data['mainImage'].split(',')[1]
with open('deck.png', 'wb') as f:
    f.write(base64.b64decode(base64_data))

/deck-json GETPOST

https://karsenal-api.netlify.app/.netlify/functions/deck-json
解析卡组并返回格式化卡牌数据。 Parse the deck and return formatted card data.
Content-Type: application/json
请求体Request Body
参数Item 类型Type 默认值Default 描述Description
deckCodestring-KARDS 卡组代码KARDS deck code
响应格式Response Format
{
  "mainFaction": "usa",
  "allyFaction": "anzac",
  "mainFactionName": "美国",
  "allyFactionName": "澳新军团",
  "totalCards": 39,
  "uniqueCards": 14,
  "cards": [
    {
      "count": 4,
      "card": {
        "id": 93750,
        "cardId": "the_war_machine",
        "importId": "bK",
        "titleZh": "战争机器",
        "titleEn": "THE WAR MACHINE",
        "text_zh": "额外获得 1 个指挥点槽。",
        "textMap": { "zh-Hans": "额外获得 1 个指挥点槽。", … },
        "titleMap": { "zh-Hans": "战争机器", … },
        "faction": "usa",
        "type": "order",
        "rarity": "Standard",
        "cost": 2,
        "attributes": [],
        "setName": "Base",
        "image": "the_war_machine.avif",
        "reserved": false,
        "isSpawn": false,
        "isVeteranSet": false,
        "canCreate": [],
        "exile": "",
        "permanentPool": true
      }
    },
    …
  ]
}
示例Example
curl -X POST https://karsenal-api.netlify.app/.netlify/functions/deck-json \
  -H "Content-Type: application/json" \
  -d '{"deckCode":"%%5a|jvpy;j3xAyc;czydj1bPmI;ggbKpEy6"}'

许可License

MIT