imgur
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImgur 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_idGet your Client ID from: https://api.imgur.com/oauth2/addclient
When registering:
- Authorization type: "OAuth 2 authorization without a callback URL"
- You only need the Client ID for anonymous uploads
Important: When usingin a command that pipes to another command, wrap the command containing$VARin$VAR. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.bash -c '...'bashbash -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包裹。由于Claude Code的一个bug,直接使用管道时环境变量会被静默清除。bash -c '...'bashbash -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
可选参数
| Parameter | Description |
|---|---|
| title | Image title |
| description | Image description |
| name | Filename |
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:
- - Public URL to use in Markdown:
data.link - - Save this to delete the image later
data.deletehash
json
{
"data": {
"id": "abc123",
"link": "https://i.imgur.com/abc123.png",
"deletehash": "xyz789"
},
"success": true,
"status": 200
}关键字段:
- - 可用于Markdown的公开URL:
data.link - - 保存此值以便后续删除图片
data.deletehash
Delete Image
删除图片
Replace with the deletehash from the upload response:
<your-deletehash>bash
curl -X DELETE https://api.imgur.com/3/image/<your-deletehash> -H "Authorization: Client-ID ${IMGUR_CLIENT_ID}"将替换为上传响应中的deletehash:
<your-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
使用指南
- Save deletehash: Store it if you need to delete images later
- Anonymous uploads: Images are not tied to any account
- Supported formats: JPEG, PNG, GIF, APNG, TIFF, BMP, PDF, XCF, WebP
- Max file size: 20MB for images, 200MB for GIFs
- 保存deletehash:如果后续需要删除图片,请妥善存储此值
- 匿名上传:图片不与任何账户绑定
- 支持格式:JPEG、PNG、GIF、APNG、TIFF、BMP、PDF、XCF、WebP
- 最大文件大小:图片20MB,GIF200MB
API Reference
API参考
- Documentation: https://apidocs.imgur.com/
- Register App: https://api.imgur.com/oauth2/addclient