summaryrefslogtreecommitdiff
path: root/templates/api.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/api.html')
-rw-r--r--[l---------]templates/api.html114
1 files changed, 113 insertions, 1 deletions
diff --git a/templates/api.html b/templates/api.html
index 7b03479..a88e584 120000..100644
--- a/templates/api.html
+++ b/templates/api.html
@@ -1 +1,113 @@
-cli.html \ No newline at end of file
+{{template "header.html" "Upload images from file!"}}
+{{template "navbar.html"}}
+{{template "modal_uploaded.html"}}
+{{template "modal_error.html"}}
+
+<div class="container">
+ <div class="row">
+ <div class="col-md-12 well">
+
+ <h1>Rest API:</h1>
+ <p>Interfacing with Mandible is extremely simple:</p>
+ <p></p>
+
+ <blockquote>
+ <h2>Upload an image file:</h2>
+ <p><code>POST {{.OriginUrl}}/api/v1/file</code></p>
+ <p>with the following multi-part/form-data</p>
+ <ul>
+ <li><code>image</code> - file</li>
+ </ul>
+ </blockquote>
+
+ <blockquote>
+ <h2>Upload an image from a URL:</h2>
+ <p><code>POST {{.OriginUrl}}/api/v1/url</code></p>
+ <p>with the following multi-part/form-data</p>
+ <ul>
+ <li><code>image</code> - file</li>
+ </ul>
+ </blockquote>
+
+ <blockquote>
+ <h2>Upload an image from base64 data:</h2>
+ <p><code>POST {{.OriginUrl}}/api/v1/base64</code></p>
+ <p>with the following multi-part/form-data</p>
+ <ul>
+ <li><code>image</code> - image encoded as base64 data</li>
+ </ul>
+ </blockquote>
+
+ <blockquote>
+ <h2>Thumbnail Generation:</h2>
+ <p>To generate thumbnails with the request, pass the following JSON as form-data, keyed under <code>thumbs</code></p>
+ <pre><code>{
+ "name1": {
+ "width": x,
+ "height": y,
+ "shape": ("square" | "thumb" | "circle")
+ },
+ "name2": {
+ "width": x2,
+ "height": y2,
+ "shape": ("square" | "thumb" | "circle")
+ },
+ ...
+}</code></pre>
+ <p>Note: Square thumbnails don't preserve aspect ratio, whereas the 'thumb' type does.</p>
+ </blockquote>
+
+ <h1>Example Usage:</h1>
+ <blockquote>
+ <h2>URL Upload with thumbnails:</h2>
+ <pre><code>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"}}'</code></pre>
+
+ <h2>Response:</h2>
+ <pre><code>{
+ "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
+}</pre></code>
+ </blockquote>
+
+ <blockquote>
+ <h2>File Upload with thumbnails:</h2>
+ <pre><code>curl -i {{.OriginUrl}}/api/v1/file \
+-F 'image=@/tmp/cat.gif' \
+-F 'thumbs={"small": {"width": 20, "height": 20, "shape": "square"}}'</pre></code>
+
+ <h2>Response:</h2>
+ <pre><code>{
+ "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
+}</pre></code>
+ </blockquote>
+ </div>
+ </div>
+</div>
+
+{{template "footer.html"}}