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.
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json;
namespace AnhMoeUpload
{
class Program
{
static void Main(string[] args)
{
string apiUrl = "https://anh.moe/api/1/upload/?key=YOUR_API_KEY&format=json";
string filePath = "/path/to/your/file.jpg";
UploadImage(apiUrl, filePath).Wait();
}
static async Task UploadImage(string apiUrl, string filePath)
{
try
{
using (var httpClient = new HttpClient())
{
using (var content = new MultipartFormDataContent())
{
var fileContent = new ByteArrayContent(File.ReadAllBytes(filePath));
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/jpeg");
content.Add(fileContent, "source", Path.GetFileName(filePath));
var response = await httpClient.PostAsync(apiUrl, content);
if (response.IsSuccessStatusCode)
{
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
else
{
throw new Exception($"Upload failed. Status code: {response.StatusCode}");
}
}
}
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
}
}
}
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.
WEBP Optimizer only supports images up to 30MB. Please select a different option if your image is larger.
Modifier télécharger
Note : Les GIFs ne seront pas redimensionnés.
Créer album
Le contenu envoyé sera déplacé vers cet album nouvellement créé. Vous devez créer un compte ou se connecter si vous souhaitez modifier cet album plus tard.