Markdown2HTML API

把 Markdown ZIP 异步导入成可投放的 HTML

上传一个包含 Markdown 和本地图片的 ZIP,创建异步导入任务。系统会自动处理图片、修正引用关系,并在任务完成后返回适合预览、分发和继续加工的 HTML 内容。

一次导入文章与配图

  • ZIP 导入,不要求人工逐张上传图片
  • 图片自动处理并上传,ZIP 本身不会进入 COS
  • 目录管理、主题样式、文章落库和 AI 对接文档整合在同一条流程里
Base URL: https://api.imgto.link

ZIP 异步导入

面向 Obsidian、知识库导出的 Markdown 文件包,保留相对图片引用,并通过任务队列稳定处理大包导入。

任务完成后返回结果

创建任务并轮询状态后,即可拿到可预览、分发或接入工作流的 HTML 结果,减少人工二次整理。

主题可控

输出风格可以保持统一,适合品牌内容、知识库发布和批量生产场景。

资源自动归档

文章和图片资源会按清晰目录归档,后续检索、复用和协作都更顺手。

适合这样使用

  1. 1

    先把 Obsidian、知识库或本地整理好的 Markdown 文章包统一打成 ZIP 并上传。

  2. 2

    再创建异步导入任务,让系统自动处理图片上传、链接替换和排版转换。

  3. 3

    轮询任务完成后,将结果继续用于网页发布、内容分发、AI 加工或内部编辑流程。

最终交付结果

  • 一份在任务完成后返回、可直接预览和嵌入下游系统的 HTML 内容
  • 一套已经处理好图片引用关系的文章素材,方便继续编辑和复用
  • 更稳定的资源目录结构,适合团队协作、归档和批量管理
  • 统一主题下的输出效果,减少不同来源 Markdown 的样式落差

API Key 与 AI 可读文档

下面这部分既是开发者控制台,也是可以直接复制给 AI 的异步接入文档。

ZIP 导入 API 文档

一键申请 API Key,复制下面这份 Markdown 指南,交给 AI 或开发同事即可按异步流程直接对接。

申请导入 API Key

请登录以访问此功能

已生成的 Key

暂无可用 API Key

主题 API 标识

接口里的 themeId 与编辑器中的主题名称保持一致,下面同时给出可读名称和颜色参考。

默认主题
themeId: warm
系统默认
经典·温暖
#ea580c
#333
中国风
themeId: china
思源宋体
古典·雅致
#7f1d1d
#292524
#f5f5f4
赛博朋克
themeId: cyber
等宽字体
未来·霓虹·科技
#ec4899
#a855f7
#3b82f6
微信经典
themeId: classic
黑体 (Sans)
干净、安全、通用
#07c160
#333
墨染宋体
themeId: ink
宋体 (Serif)
文化、历史、传统
#3f3f46
#78716c
杂志排版
themeId: editorial
衬线+黑体
时尚、艺术、高级灰
#1f2937
#ef4444
治愈文楷
themeId: wenkai
霞鹜文楷
情感、生活、手写感
#57534e
#78716c
深度阅读
themeId: business
系统黑体
商业、科技、干货
#1e3a8a
#1e40af
绿野仙踪
themeId: forest
黑体 (Sans)
自然、旅行、清新
#059669
#ecfdf5
蔚蓝海岸
themeId: azure
黑体 (Sans)
科技、夏日、通透
#0ea5e9
#e0f2fe
醇香咖啡
themeId: coffee
宋体 (Serif)
复古、故事、温暖
#78350f
#fffbeb
赛博霓虹
themeId: neon
等宽 (Mono)
极客、前沿、潮流
#d946ef
#06b6d4
东方红韵
themeId: red
宋体 (Serif)
国潮、节日、典雅
#be123c
#fff1f2
极客银灰
themeId: silver
黑体 (Sans)
理性、冷淡、专业
#475569
#e2e8f0
极简留白
themeId: minimal
无衬线
摄影、设计、冷淡
#000
#999
莫兰迪粉
themeId: morandi
思源宋体
美妆、女性、温柔
#be185d
#fbcfe8
暖阳活力
themeId: sunny
快乐体
美食、探店、年轻
#f97316
#fbbf24
薄荷夏日
themeId: mint
圆体 (Sans)
清凉、生活、治愈
#10b981
#d1fae5
金秋拾光
themeId: autumn
宋体 (Serif)
温暖、故事、情感
#d97706
#fef3c7
普罗旺斯
themeId: lavender
宋体 (Serif)
梦幻、浪漫、唯美
#8b5cf6
#ede9fe
胶片电影
themeId: vintage
黑体 (Sans)
复古、暗调、影评
#7f1d1d
#fecaca
读书笔记
themeId: notes
霞鹜文楷
高亮、手写、干货
#facc15
#fef08a
高级烟灰
themeId: grey
黑体 (Sans)
极简、冷淡、质感
#374151
#f3f4f6

AI 可读 API 对接文档

Imgto.link Markdown ZIP Import API

What this API does

  • Upload one ZIP package containing one Markdown file and its local images
  • Queue an asynchronous import job
  • Automatically create the target image directory if it does not exist
  • Automatically save the imported Markdown into the article folder 公众号
  • Upload referenced images to Imgto.link storage
  • Replace local image references in Markdown
  • Return the final resolved Markdown, HTML output, saved article info, and image directory path after the job completes

Base URL

https://api.imgto.link

Endpoints on the same host

  • ZIP upload endpoint: POST https://api.imgto.link/uploads/md-import
  • Create import job: POST https://api.imgto.link/api/v1/md/import
  • Poll job status: GET https://api.imgto.link/api/v1/md/import/jobs/{jobId}
  • In production you can proxy the control-plane routes on the same https://api.imgto.link host, so clients only need one public base URL.

Authentication

Use an API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Async workflow

  1. Upload the ZIP archive to the upload endpoint and get back uploadRelativePath
  2. Create an async import job with POST https://api.imgto.link/api/v1/md/import
  3. Poll GET https://api.imgto.link/api/v1/md/import/jobs/{jobId} until the job reaches a terminal status

Step 1: upload ZIP archive

Endpoint

POST https://api.imgto.link/uploads/md-import

Content-Type

multipart/form-data

Form fields

  • archive (required): ZIP file containing one Markdown file and its local image files

Success response

{
  "code": 200,
  "data": {
    "relativePath": "inbox/2026/03/12/uuid-article-package.zip",
    "originalFilename": "article-package.zip",
    "size": 345678,
    "uploadedAt": "2026-03-12T08:00:00.000Z"
  }
}

Step 2: create import job

Endpoint

POST https://api.imgto.link/api/v1/md/import

Content-Type

application/json

Request body

{
  "uploadRelativePath": "inbox/2026/03/12/uuid-article-package.zip",
  "archiveFilename": "article-package.zip",
  "archiveSize": 345678,
  "themeId": "classic",
  "directoryPath": "public/articles/demo",
  "entryMarkdown": "docs/index.md",
  "saveFolderId": 12,
  "mdfileId": 123
}

Request field notes

  • uploadRelativePath (required): value returned from step 1
  • archiveFilename (required): original zip filename
  • archiveSize (optional): archive size in bytes
  • themeId (optional): theme API name, default is classic
  • directoryPath (optional): base upload directory path like public/articles/launch-2026
  • entryMarkdown (optional): specific markdown file path inside the ZIP when there are multiple markdown files
  • saveFolderId (optional): target markdown folder ID in the editor
  • mdfileId (optional): existing markdown article ID. When provided, the import is treated as a replace/update. The old article and its imported images are deleted before the new content is saved

Success response

{
  "code": 202,
  "message": "Accepted",
  "data": {
    "jobId": "mdi_1234567890abcdef",
    "status": "QUEUED",
    "progress": 0,
    "pollUrl": "/api/v1/md/import/jobs/mdi_1234567890abcdef"
  }
}

Step 3: poll job status

Endpoint

GET https://api.imgto.link/api/v1/md/import/jobs/{jobId}

Non-terminal response example

{
  "code": 200,
  "message": "Ok",
  "data": {
    "jobId": "mdi_1234567890abcdef",
    "status": "PROCESSING",
    "progress": 65,
    "currentStage": "processing_images",
    "message": "正在处理图片 2/4",
    "compensationStatus": "NOT_REQUIRED",
    "updatedAt": "2026-03-12T08:01:15.000Z"
  }
}

Completed response example

{
  "code": 200,
  "message": "Ok",
  "data": {
    "jobId": "mdi_1234567890abcdef",
    "status": "SUCCEEDED",
    "progress": 100,
    "currentStage": "completed",
    "message": "导入完成",
    "compensationStatus": "NOT_REQUIRED",
    "updatedAt": "2026-03-12T08:01:30.000Z",
    "result": {
      "mdfileId": 123,
      "resolvedMarkdown": "# Title\n\n![cover](https://...)",
      "html": "<section>...</section>",
      "wechatApiHtml": "<section>...</section>",
      "imageDirectoryPath": "public/公众号/my-article",
      "savedArticle": {
        "id": 123,
        "mdfileId": 123,
        "title": "My Article",
        "folder": {
          "id": 9,
          "name": "公众号",
          "fullPath": "公众号"
        }
      }
    }
  }
}

Failed response example

{
  "code": 200,
  "message": "Ok",
  "data": {
    "jobId": "mdi_1234567890abcdef",
    "status": "FAILED_COMPENSATED",
    "progress": 100,
    "currentStage": "failed",
    "message": "导入失败,已回滚上传图片与用户额度",
    "compensationStatus": "COMPLETED",
    "updatedAt": "2026-03-12T08:02:00.000Z",
    "error": {
      "message": "Referenced image not found: ./images/cover.png"
    }
  }
}

Job status notes

  • Terminal success status: SUCCEEDED
  • Terminal failure status: FAILED_COMPENSATED
  • Transitional failure statuses can appear briefly during rollback, such as FAILED_PENDING_COMPENSATION and FAILED_COMPENSATION_ERROR
  • result is returned only when the job succeeds
  • error is returned when the job fails

Result field notes

  • result.resolvedMarkdown: Markdown after local image paths are replaced with Imgto.link URLs
  • result.html: Base rendered HTML for preview or debugging
  • result.wechatApiHtml: Recommended HTML for submitting to the WeChat Official Account API content field
  • result.mdfileId: The saved Markdown article ID, returned for convenient reuse in the next replace import request
  • result.savedArticle: Saved Markdown article record in the editor
  • result.savedArticle.mdfileId: Stable article identifier to pass back on the next import if you want to replace this article instead of creating a new one
  • result.imageDirectoryPath: Final image upload directory path

Example cURL: step 1 upload

curl -X POST "https://api.imgto.link/uploads/md-import" \
  -F "archive=@article-package.zip" \

Example cURL: step 2 create job

curl -X POST "https://api.imgto.link/api/v1/md/import" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "uploadRelativePath": "inbox/2026/03/12/uuid-article-package.zip",
    "archiveFilename": "article-package.zip",
    "archiveSize": 345678,
    "themeId": "classic",
    "directoryPath": "public/articles/demo"
  }'

Example cURL: step 3 poll job

curl -X GET "https://api.imgto.link/api/v1/md/import/jobs/mdi_1234567890abcdef" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example JavaScript: end-to-end async import

const uploadFormData = new FormData();
uploadFormData.append("archive", zipFile);

const uploadResponse = await fetch("https://api.imgto.link/uploads/md-import", {
  method: "POST",
  body: uploadFormData
});

const uploadResult = await uploadResponse.json();
const relativePath = uploadResult.data.relativePath;

const createResponse = await fetch("https://api.imgto.link/api/v1/md/import", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    uploadRelativePath: relativePath,
    archiveFilename: uploadResult.data.originalFilename,
    archiveSize: uploadResult.data.size,
    themeId: "classic",
    directoryPath: "public/articles/demo"
  })
});

const createResult = await createResponse.json();
const jobId = createResult.data.jobId;

let finalResult = null;

for (;;) {
  const pollResponse = await fetch("https://api.imgto.link/api/v1/md/import/jobs/" + jobId, {
    method: "GET",
    headers: {
      Authorization: "Bearer YOUR_API_KEY"
    }
  });

  const pollResult = await pollResponse.json();
  const job = pollResult.data;

  if (job.status === "SUCCEEDED") {
    finalResult = job.result;
    break;
  }

  if (job.status === "FAILED_COMPENSATED") {
    throw new Error(job.error?.message || "Import failed");
  }

  await new Promise((resolve) => setTimeout(resolve, 1800));
}

console.log(finalResult.mdfileId);
console.log(finalResult.resolvedMarkdown);
console.log(finalResult.wechatApiHtml);
console.log(finalResult.savedArticle);

Example: replace an existing imported article

Use the result.savedArticle.mdfileId returned by the previous successful import job.

const replaceResponse = await fetch("https://api.imgto.link/api/v1/md/import", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    uploadRelativePath: uploadedZip.data.relativePath,
    archiveFilename: uploadedZip.data.originalFilename,
    archiveSize: uploadedZip.data.size,
    themeId: "classic",
    mdfileId: previousResult.savedArticle.mdfileId
  })
});

const replaceResult = await replaceResponse.json();
console.log(replaceResult.data.jobId);

Replace behavior

  • mdfileId omitted: create a new import job using the uploaded ZIP
  • mdfileId provided: force this import to replace that exact article
  • During replacement, the job deletes the old markdown record first
  • It also deletes images previously imported for that markdown article before uploading the new images
  • Read the latest mdfileId from the final successful poll result and keep using it for future updates

Example: publish to WeChat Official Account draft API

Use result.wechatApiHtml from the completed import job for the content field instead of result.html.

const completedImport = await waitForImportJob(jobId);
const wechatApiHtml = completedImport.result.wechatApiHtml;

const draftPayload = {
  articles: [
    {
      title: completedImport.result.savedArticle?.title || "Imported article",
      author: "Your Team",
      digest: "",
      content: wechatApiHtml,
      content_source_url: "",
      thumb_media_id: "YOUR_WECHAT_THUMB_MEDIA_ID",
      need_open_comment: 0,
      only_fans_can_comment: 0
    }
  ]
};

const wechatResponse = await fetch(
  "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=YOUR_WECHAT_ACCESS_TOKEN",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify(draftPayload)
  }
);

const wechatResult = await wechatResponse.json();
console.log(wechatResult);

WeChat publishing note

  • Prefer result.wechatApiHtml for WeChat Official Account API publishing
  • Do not use result.html as the content field if you need output aligned with the website's copy/export flow
  • Image URLs inside result.wechatApiHtml should already point to uploaded Imgto.link assets
  • You still need to provide your own WeChat access_token and thumb_media_id

Theme API names

  • 默认主题 (warm): #ea580c, #333
  • 中国风 (china): #7f1d1d, #292524, #f5f5f4
  • 赛博朋克 (cyber): #ec4899, #a855f7, #3b82f6
  • 微信经典 (classic): #07c160, #333
  • 墨染宋体 (ink): #3f3f46, #78716c
  • 杂志排版 (editorial): #1f2937, #ef4444
  • 治愈文楷 (wenkai): #57534e, #78716c
  • 深度阅读 (business): #1e3a8a, #1e40af
  • 绿野仙踪 (forest): #059669, #ecfdf5
  • 蔚蓝海岸 (azure): #0ea5e9, #e0f2fe
  • 醇香咖啡 (coffee): #78350f, #fffbeb
  • 赛博霓虹 (neon): #d946ef, #06b6d4
  • 东方红韵 (red): #be123c, #fff1f2
  • 极客银灰 (silver): #475569, #e2e8f0
  • 极简留白 (minimal): #000, #999
  • 莫兰迪粉 (morandi): #be185d, #fbcfe8
  • 暖阳活力 (sunny): #f97316, #fbbf24
  • 薄荷夏日 (mint): #10b981, #d1fae5
  • 金秋拾光 (autumn): #d97706, #fef3c7
  • 普罗旺斯 (lavender): #8b5cf6, #ede9fe
  • 胶片电影 (vintage): #7f1d1d, #fecaca
  • 读书笔记 (notes): #facc15, #fef08a
  • 高级烟灰 (grey): #374151, #f3f4f6

ZIP package rules

  • Include exactly one Markdown file, or pass entryMarkdown
  • Reference local images with relative paths such as ./images/a.png
  • Remote image URLs are kept as-is
  • The API converts static images to AVIF by default
  • The imported Markdown is automatically saved to the article folder 公众号
  • The image upload directory becomes {directoryPath}/{article-slug}

AI integration instruction

If you give this API to an AI coding assistant, tell it:

"Use the async workflow. First upload the ZIP to https://api.imgto.link/uploads/md-import with multipart/form-data and read data.relativePath, data.originalFilename, and data.size. Then call POST https://api.imgto.link/api/v1/md/import with JSON using uploadRelativePath, archiveFilename, and optional themeId, directoryPath, entryMarkdown, saveFolderId, and mdfileId. Authenticate the control-plane API with Authorization: Bearer YOUR_API_KEY. Then poll GET https://api.imgto.link/api/v1/md/import/jobs/{jobId} until status becomes SUCCEEDED or FAILED_COMPENSATED. On success, read result.resolvedMarkdown, result.wechatApiHtml, result.savedArticle, result.mdfileId, and result.imageDirectoryPath. Prefer result.wechatApiHtml when publishing to the WeChat Official Account API content field."

查看原始 Markdown