Anh.Moe API v1 cho phép mọi người sử dụng api để upload lên website.
Khoá API v1 của Anh.Moe là : anh.moe_public_api
Để dùng api riêng vui lòng đăng ký tài khoản và truy cập vào cài đặt để lấy :
https://anh.moe/settings/api
Các lệnh gọi API v1 có thể được thực hiện bằng cách sử dụng các phương thức yêu cầu POST hoặc GET nhưng vì yêu cầu GET bị giới hạn bởi độ dài tối đa cho phép của một URL, vì vậy bạn nên sử dụng phương thức yêu cầu POST hơn.
https://anh.moe/api/1/upload/
key
Đây là khoá API, bạn có thể lấy ở mục API key bên trên.action
Hành động bạn muốn thực hiện [giá trị: upload].source
Cho phép ảnh đã được encode thành chuỗi base64 (opens new window). Bạn cũng có thể sử dụng FILES["source"] trong request.format
Đặt kiểu trả về [giá trị: json (mặc định), redirect, txt].GET https://anh.moe/api/1/upload/?key=anh.moe_public_api&source=FILES["source"]&format=json
Lưu ý: Luôn sử dụng POST khi upload file trực tiếp từ trên máy. Url encoding có thể thay đổi nguồn base64 do các ký tự được mã hóa hoặc chỉ do giới hạn độ dài yêu cầu URL do yêu cầu GET.
API v1 responses will vary depending on the format parameter:
json
Hiển thị tất cả thông tin về ảnh đã upload trong JSON. [mặc định]txt
Trả về link tải ảnh trực tiếp.redirect
Trả về link xem ảnh trên website.Khi sử dụng JSON, phản hồi sẽ có mã trạng thái tiêu đề để cho phép bạn dễ dàng nhận biết nếu yêu cầu đã OK hay không. Nó cũng sẽ xuất ra thuộc tính status_txt
và status_code
.
{
"status_code": 200,
"success": {
"message": "image uploaded",
"code": 200
},
"image": {
"name": "example",
"extension": "png",
"size": 53237,
"width": 1151,
"height": 898,
"date": "2014-06-04 15:32:33",
"date_gmt": "2014-06-04 19:32:33",
"storage_id": null,
"description": null,
"nsfw": "0",
"md5": "c684350d722c956c362ab70299735830",
"storage": "datefolder",
"original_filename": "example.png",
"original_exifdata": null,
"views": "0",
"id_encoded": "L",
"filename": "example.png",
"ratio": 1.2817371937639,
"size_formatted": "52 KB",
"mime": "image/png",
"bits": 8,
"channels": null,
"url": "http://127.0.0.1/images/2014/06/04/example.png",
"url_viewer": "http://127.0.0.1/image/L",
"thumb": {
"filename": "example.th.png",
"name": "example.th",
"width": 160,
"height": 160,
"ratio": 1,
"size": 17848,
"size_formatted": "17.4 KB",
"mime": "image/png",
"extension": "png",
"bits": 8,
"channels": null,
"url": "http://127.0.0.1/images/2014/06/04/example.th.png"
},
"medium": {
"filename": "example.md.png",
"name": "example.md",
"width": 500,
"height": 390,
"ratio": 1.2820512820513,
"size": 104448,
"size_formatted": "102 KB",
"mime": "image/png",
"extension": "png",
"bits": 8,
"channels": null,
"url": "http://127.0.0.1/images/2014/06/04/example.md.png"
},
"views_label": "views",
"display_url": "http://127.0.0.1/images/2014/06/04/example.md.png",
"how_long_ago": "moments ago"
},
"status_txt": "OK"
}
http://127.0.0.1/images/2014/06/04/example.png
The uploaded content will be moved to this newly created album. You must tạo tài khoản or đăng nhập if you want to edit this album later on.