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

/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:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| markdown | string | no | "# Default markdown" | The Markdown text to convert |
| theme | string | no | "apple-notes" | Card theme style ID |
| themeMode | string | no | limited per theme | Theme mode ID (e.g., light-mode, dark-mode) |
| width | number | no | 440 | Card width (px) |
| height | number | no | 586 | Card height (px) |
| splitMode | string | no | "noSplit" | Split mode: autoSplit, noSplit, hrSplit |
| mdxMode | boolean | no | false | Enable MDX mode |
| overHiddenMode | boolean | no | false | Enable overflow-hidden mode |
Available Themes
| Chinese Name | English Name | ID | Theme Mode IDs |
|---|---|---|---|
| 苹果备忘录 | Apple Notes | apple-notes | light-mode, dark-mode |
| 线圈笔记本 | Coil Notebook | coil-notebook | blue-mode, pink-mode, mint-mode, yellow-mode |
| 波普艺术 | Pop Art | pop-art | default-mode, pink-blue-mode, mint-mode, purple-mode |
| 字节范 | ByteDance | bytedance | |
| 阿里橙 | Alibaba | alibaba | |
| 艺术装饰 | Art deco | art-deco | |
| 玻璃拟态 | Glass Morphism | glassmorphism | |
| 温暖柔和 | Warm & Soft | warm | |
| 简约高级灰 | Minimal Gray | minimal | |
| 极简黑白 | Minimalist B&W | minimalist | |
| 梦幻渐变 | Dreamy Gradient | dreamy | |
| 清新自然 | Fresh Nature | nature | |
| 紫色小红书 | Purple Social | xiaohongshu | |
| 笔记本 | Notebook | notebook | |
| 暗黑科技 | Dark Tech | darktech | |
| 复古打字机 | Vintage Typewriter | typewriter | |
| 水彩艺术 | Watercolor Art | watercolor | |
| 中国传统 | Traditional Chinese | traditional-chinese | |
| 儿童童话 | Children's Fairy Tale | fairytale | |
| 商务简报 | Business Brief | business | |
| 日本杂志 | Japanese Magazine | japanese-magazine | |
| 赛博朋克 | Cyberpunk | cyberpunk | |
| 青野晨光 | meadow dawn | meadow-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
- The first call may take some processing time
- Generated images are uploaded to Tencent Cloud COS, and a public URL is returned
- Request timeout is 60 seconds; overly long processing will return an error
- Set reasonable card dimensions to avoid overly large images