MD2Card API Documentation

api docs
Generate knowledge card images using the API
MD2Card API Documentation

/api/generate

Convert Markdown text into beautifully styled card images.

Authentication

Use an API Key for authentication. Add x-api-key in the request headers.

x-api-key: your_api_key

Method

POST

Request Body

JSON payload with the following fields:

FieldTypeRequiredDefaultDescription
markdownstringno"# Default markdown"The Markdown text to convert
themestringno"apple-notes"Card theme style ID
themeModestringnolimited per themeTheme mode ID (e.g., light-mode, dark-mode)
widthnumberno440Card width (px)
heightnumberno586Card height (px)
splitModestringno"noSplit"Split mode: autoSplit, noSplit, hrSplit
mdxModebooleannofalseEnable MDX mode
overHiddenModebooleannofalseEnable overflow-hidden mode

Available Themes

Chinese NameEnglish NameIDTheme Mode IDs
苹果备忘录Apple Notesapple-noteslight-mode, dark-mode
线圈笔记本Coil Notebookcoil-notebookblue-mode, pink-mode, mint-mode, yellow-mode
波普艺术Pop Artpop-artdefault-mode, pink-blue-mode, mint-mode, purple-mode
字节范ByteDancebytedance
阿里橙Alibabaalibaba
艺术装饰Art decoart-deco
玻璃拟态Glass Morphismglassmorphism
温暖柔和Warm & Softwarm
简约高级灰Minimal Grayminimal
极简黑白Minimalist B&Wminimalist
梦幻渐变Dreamy Gradientdreamy
清新自然Fresh Naturenature
紫色小红书Purple Socialxiaohongshu
笔记本Notebooknotebook
暗黑科技Dark Techdarktech
复古打字机Vintage Typewritertypewriter
水彩艺术Watercolor Artwatercolor
中国传统Traditional Chinesetraditional-chinese
儿童童话Children's Fairy Talefairytale
商务简报Business Briefbusiness
日本杂志Japanese Magazinejapanese-magazine
赛博朋克Cyberpunkcyberpunk
青野晨光meadow dawnmeadow-dawn

You can also use custom themes by specifying a custom CSS class name. Click the icon next to the theme name to view supported theme mode IDs.

Response Format

Success

{
  "images": [
    {
      "url": "https://md2crad-1256585691.cos-website.ap-shanghai.myqcloud.com/screenshots/1234567890_abc.png",
      "fileName": "screenshots/1234567890_abc.png"
    }
  ]
}

Error

{
  "error": "Processing failed",
  "message": "Error details"
}

Example

curl -X POST 'https://md2card.cn/api/generate' \
  -H 'x-api-key: 69dc693bf34b45cd9ccbadc9819dd547590edbcab88e472bb9bf45a41562c3fc' \
  -H 'Content-Type: application/json' \
  -d '{
    "markdown": "# Hello World\n md2card api docs",
    "theme": "apple-notes",
    "width": 440,
    "height": 586
  }'

Notes

  1. The first call may take some processing time
  2. Generated images are uploaded to Tencent Cloud COS, and a public URL is returned
  3. Request timeout is 60 seconds; overly long processing will return an error
  4. Set reasonable card dimensions to avoid overly large images