imgur

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Imgur Image Hosting

Imgur 图片托管

Imgur is a free image hosting service. Upload images and get URLs for sharing, embedding in articles, or using in documentation.
Imgur是一项免费的图片托管服务。你可以上传图片并获取URL,用于分享、嵌入文章或在文档中使用。

When to Use

使用场景

  • Upload images to get shareable URLs
  • Host images for blog posts or documentation
  • Get image URLs for use in Markdown content
  • Anonymous image uploads (no account needed)
  • 上传图片以获取可分享的URL
  • 为博客文章或文档托管图片
  • 获取图片URL用于Markdown内容
  • 匿名上传图片(无需账户)

Prerequisites

前置条件

Set the following environment variable:
bash
export IMGUR_CLIENT_ID=your_client_id
When registering:
  • Authorization type: "OAuth 2 authorization without a callback URL"
  • You only need the Client ID for anonymous uploads
Important: When using
$VAR
in a command that pipes to another command, wrap the command containing
$VAR
in
bash -c '...'
. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'
设置以下环境变量:
bash
export IMGUR_CLIENT_ID=your_client_id
从以下链接获取你的Client ID:https://api.imgur.com/oauth2/addclient
注册时:
  • 授权类型:“OAuth 2 authorization without a callback URL”(无回调URL的OAuth 2授权)
  • 匿名上传仅需Client ID
重要提示: 当在包含管道的命令中使用
$VAR
时,请将包含
$VAR
的命令用
bash -c '...'
包裹。由于Claude Code的一个bug,直接使用管道时环境变量会被静默清除。
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'

How to Use

使用方法

Upload Local Image

上传本地图片

bash
curl -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F "image=@/path/to/image.png"
bash
curl -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F "image=@/path/to/image.png"

Upload from URL

从URL上传

bash
curl -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F "image=https://example.com/image.png" -F "type=url"
bash
curl -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F "image=https://example.com/image.png" -F "type=url"

Upload Base64

上传Base64格式图片

bash
curl -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F "image=$(base64 -i /path/to/image.png)" -F "type=base64"
bash
curl -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F "image=$(base64 -i /path/to/image.png)" -F "type=base64"

Optional Parameters

可选参数

ParameterDescription
titleImage title
descriptionImage description
nameFilename
bash
curl -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F "image=@screenshot.png" -F "title=My Screenshot" -F "description=Screenshot from my app"
参数描述
title图片标题
description图片描述
name文件名
bash
curl -X POST https://api.imgur.com/3/image -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}" -F "image=@screenshot.png" -F "title=My Screenshot" -F "description=Screenshot from my app"

Response

响应示例

json
{
  "data": {
  "id": "abc123",
  "link": "https://i.imgur.com/abc123.png",
  "deletehash": "xyz789"
  },
  "success": true,
  "status": 200
}
Key fields:
  • data.link
    - Public URL to use in Markdown:
    ![img](https://i.imgur.com/abc123.png)
  • data.deletehash
    - Save this to delete the image later
json
{
  "data": {
  "id": "abc123",
  "link": "https://i.imgur.com/abc123.png",
  "deletehash": "xyz789"
  },
  "success": true,
  "status": 200
}
关键字段:
  • data.link
    - 可用于Markdown的公开URL:
    ![img](https://i.imgur.com/abc123.png)
  • data.deletehash
    - 保存此值以便后续删除图片

Delete Image

删除图片

Replace
<your-deletehash>
with the deletehash from the upload response:
bash
curl -X DELETE https://api.imgur.com/3/image/<your-deletehash> -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}"
<your-deletehash>
替换为上传响应中的deletehash:
bash
curl -X DELETE https://api.imgur.com/3/image/<your-deletehash> -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}"

Rate Limits

速率限制

  • ~12,500 requests/day
  • ~1,250 uploads/day (uploads cost 10 credits)
  • Headers show remaining:
    X-RateLimit-ClientRemaining
  • 每日约12,500次请求
  • 每日约1,250次上传(每次上传消耗10个积分)
  • 响应头中显示剩余额度:
    X-RateLimit-ClientRemaining

Guidelines

使用指南

  1. Save deletehash: Store it if you need to delete images later
  2. Anonymous uploads: Images are not tied to any account
  3. Supported formats: JPEG, PNG, GIF, APNG, TIFF, BMP, PDF, XCF, WebP
  4. Max file size: 20MB for images, 200MB for GIFs
  1. 保存deletehash:如果后续需要删除图片,请妥善存储此值
  2. 匿名上传:图片不与任何账户绑定
  3. 支持格式:JPEG、PNG、GIF、APNG、TIFF、BMP、PDF、XCF、WebP
  4. 最大文件大小:图片20MB,GIF200MB

API Reference

API参考