From b3fa125ed0292f8ca37e91bf19c8cae7cdacc506 Mon Sep 17 00:00:00 2001 From: horus_arch Date: Tue, 21 Apr 2015 01:47:42 +0200 Subject: Add API documentation and better defaults. --- templates/api.html | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) mode change 120000 => 100644 templates/api.html (limited to 'templates/api.html') diff --git a/templates/api.html b/templates/api.html deleted file mode 120000 index 7b03479..0000000 --- a/templates/api.html +++ /dev/null @@ -1 +0,0 @@ -cli.html \ No newline at end of file diff --git a/templates/api.html b/templates/api.html new file mode 100644 index 0000000..a88e584 --- /dev/null +++ b/templates/api.html @@ -0,0 +1,113 @@ +{{template "header.html" "Upload images from file!"}} +{{template "navbar.html"}} +{{template "modal_uploaded.html"}} +{{template "modal_error.html"}} + +
+
+
+ +

Rest API:

+

Interfacing with Mandible is extremely simple:

+

+ +
+

Upload an image file:

+

POST {{.OriginUrl}}/api/v1/file

+

with the following multi-part/form-data

+
    +
  • image - file
  • +
+
+ +
+

Upload an image from a URL:

+

POST {{.OriginUrl}}/api/v1/url

+

with the following multi-part/form-data

+
    +
  • image - file
  • +
+
+ +
+

Upload an image from base64 data:

+

POST {{.OriginUrl}}/api/v1/base64

+

with the following multi-part/form-data

+
    +
  • image - image encoded as base64 data
  • +
+
+ +
+

Thumbnail Generation:

+

To generate thumbnails with the request, pass the following JSON as form-data, keyed under thumbs

+
{
+	"name1": {
+		"width": x,
+		"height": y,
+		"shape": ("square" | "thumb" | "circle")
+	},
+	"name2": {
+		"width": x2,
+		"height": y2,
+		"shape": ("square" | "thumb" | "circle")
+	},
+	...
+}
+

Note: Square thumbnails don't preserve aspect ratio, whereas the 'thumb' type does.

+
+ +

Example Usage:

+
+

URL Upload with thumbnails:

+
curl -i {{.OriginUrl}}/api/v1/url \
+-d 'image=http://i.imgur.com/s9zxmYe.jpg' \
+-d 'thumbs={"small": {"width": 20, "height": 20, "shape": "square"}, "profile": {"width": 50, "height": 50, "shape": "circle"}}'
+ +

Response:

+
{
+    "data": {
+        "width": 380,
+        "height": 430,
+        "link": "{{.ResponseUrl}}/i/Y/h/Yhs6srW",
+        "mime": "image/jpeg",
+        "name": "",
+        "size": 82199,
+        "thumbs": {
+            "profile":"{{.ResponseUrl}}/t/Y/h/Yhs6srW/profile",
+            "small": "{{.ResponseUrl}}/t/Y/h/Yhs6srW/small"
+        }
+    },
+    "status": 200,
+    "success": true
+}
+
+ +
+

File Upload with thumbnails:

+
curl -i {{.OriginUrl}}/api/v1/file \
+-F 'image=@/tmp/cat.gif' \
+-F 'thumbs={"small": {"width": 20, "height": 20, "shape": "square"}}'
+ +

Response:

+
{
+    "data": {
+        "width": 354,
+        "height": 200,
+        "link": "{{.ResponseUrl}}/i/U/v/UvfuzBW",
+        "mime": "image/gif",
+        "name": "cat.gif",
+        "size": 3511100,
+        "thumbs": {
+            "small":"{{.ResponseUrl}}/t/U/v/UvfuzBW/small"
+        }
+    },
+    "status": 200,
+    "success": true
+}
+
+
+
+
+ +{{template "footer.html"}} -- cgit v1.2.3