{"slug":"ipfs-api","title":"分享一个IPFS图片API","description":"很早前我就用过xLog，这次逆向出了它的图床API，可以用来暂时存放图片！","coverImage":"https://b.acofork.com/img/ipfs-api-2a104c9e-195b-4f16-b080-ee76c763a80a.webp","coverWidth":868,"coverHeight":706,"date":"2025-07-03","tags":["开发"],"pinned":false,"wordCount":119,"html":"<h2 id=\"正式开始\">正式开始</h2><blockquote>\n<p>该API为<a href=\"https://xlog.app\" target=\"_blank\" rel=\"noopener noreferrer\">xLog</a>的图床API</p>\n</blockquote>\n<p>POST <a href=\"https://ipfs-relay.crossbell.io/upload\" target=\"_blank\" rel=\"noopener noreferrer\">https://ipfs-relay.crossbell.io/upload</a></p>\n<p>头无鉴权</p>\n<p>body使用 <code>from-data</code> ，key为 <code>file</code> vlaue选择一个图片文件，不宜太大，会报错</p>\n<p>示例Curl</p>\n<div class=\"markdown-code\" data-language=\"bash\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19h8\"></path><path d=\"m4 17 6-6-6-6\"></path></svg><span>bash</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-bash\">curl --location <span class=\"hljs-string\">'https://ipfs-relay.crossbell.io/upload'</span> \\\n--form <span class=\"hljs-string\">'file=@\"/C:/Users/AcoFork/Pictures/b_53bb4f7fa91d684e72b666504e3fcc1897.webp\"'</span></code></pre></div><p>会返回</p>\n<div class=\"markdown-code\" data-language=\"json\"><div class=\"markdown-code-header\"><span class=\"markdown-code-language\"><svg class=\"code-language-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1\"></path><path d=\"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 0-2-2V5a2 2 0 0 0-2-2h-1\"></path></svg><span>json</span></span><button type=\"button\" class=\"code-block-copy\" aria-label=\"复制代码\" title=\"复制代码\"><svg class=\"code-block-copy-icon\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"></rect><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"></path></svg></button></div><pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n    <span class=\"hljs-attr\">\"status\"</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">\"ok\"</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">\"cid\"</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">\"QmVHG3KdGs3M8otdqjZEei6AzWt1usWRP6UmfLMbEub5nc\"</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">\"url\"</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">\"ipfs://QmVHG3KdGs3M8otdqjZEei6AzWt1usWRP6UmfLMbEub5nc\"</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">\"web2url\"</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">\"https://ipfs.crossbell.io/ipfs/QmVHG3KdGs3M8otdqjZEei6AzWt1usWRP6UmfLMbEub5nc\"</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">\"fileSize\"</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">\"77199\"</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">\"gnfd_id\"</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">null</span></span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">\"gnfd_txn\"</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">null</span></span>\n<span class=\"hljs-punctuation\">}</span></code></pre></div><p>其中， <code>web2url</code> 就是可以直接访问的URL，无CORS限制</p>\n<p><img src=\"https://b.acofork.com/img/ipfs-api-Qmb7hj9NHf9XdSZQ2dsqcSUpdrTuhjbpKJsTqG84X7rFqw.webp\" alt=\"\" width=\"299\" height=\"79\" loading=\"eager\" decoding=\"async\" /></p>\n","toc":[{"id":"正式开始","text":"正式开始","depth":2}]}