API version 1.1

We now support more upload parameters for user API keys, including title, width, and more!

Our public API has some limitations, such as a maximum upload size of 20MB per image and the inability to manage or delete images after they have been uploaded.

Therefore, we encourage you to use our private API, which offers a maximum image size of 50MB and allows you to manage your images. Click the button below to go to the API access page.

Request method

You have the option of using POST or GET requests for API v1.1 calls. Since GET requests have URL length restrictions, it's usually better to go with the POST method.

Request URL

 

Authorization

API V1.1 supports header-based authorization by passing the X-API-Key header with your API key.


Parameters

Required Parameters

Name Description
source FILES["source"] or a base64 (opens new window) encoded image string..
key The API key

Optional Parameters

Name Description
title Image title
description Image description
album_id Image album id, must be owned by the user (encoded string)
category_id Category id (integer)
width Target resize width (automatic height)
expiration Expiration time to auto-delete the image
format Return format, values json, redirect, txt

Expiration table

Value Expires after
PT5M 5 minutes
PT15M 15 minutes
PT30M 30 minutes
PT1H 1 hour
PT3H 3 hours
PT6H 6 hours
PT12H 12 hours
P1D 1 day
P2D 2 days
P3D 3 days
P4D 4 days
P5D 5 days
P6D 6 days
P1W 1 week
P2W 2 weeks
P3W 3 weeks
P1M 1 month
P2M 2 months
P3M 3 months
P4M 4 months
P5M 5 months
P6M 6 months
P1Y 1 year

Example call

POST https://anh.moe/api/1/upload/?key=YOUR_API_KEY&source=FILES["source"]&format=json

Important: Always use POST requests for uploading local files. URL encoding can corrupt Base64-encoded image data due to character conversion or GET request length limits.

API response

The API will provide different types of answers depending on the format parameter.

Format Output
json Image upload info in JSONformat (default)
txt Image direct URL in text/plain format
redirect Redirects to the image viewer URL

API v1 responses provide the complete details of an uploaded image in JSON format.

The JSON response will include header status codes, making it easy to determine if the image upload request was successful or encountered an error. The response will also contain status properties for more specific information.

Example response (JSON)

Example response (txt)

https://cdn.anh.moe/c/example.jpeg
您也可以 浏览您的计算机.
您也可以 browse from deviceuse camera
JPG JPEG PNG GIF WEBP MOV MP4 WEBM max 100 MB
在任何预览上 点击 自定义上传
在任何预览上 触摸 自定义上传
您也可以 浏览您的计算机.
您也可以 browse from deviceuse camera
上传 0 文件 (0% 完成)
队列上传中. 顷刻间便能完成.
上传完毕
图片已经添加到 . 您可以将刚刚上传的图片 创建新的 相册.
图片已经添加到 .
您可以将刚刚上传的图片 创建新的 相册. 您必须 注册账户登录 才能将此内容保存到您的帐户中。
没有 文件被上传
发生了某些错误,系统无法处理您的请求。
    注意:部分文件无法上传。 了解更多
    检查 错误报告 更多信息.