-
Jonas Leder authoredJonas Leder authored
apiDocs.html 2.70 KiB
<head>
<style>
table tr:nth-child(even) {
background-color: #eee;
}
table tr:nth-child(odd) {
background-color: #fff;
}
table th {
background-color: black;
color: white;
}
</style>
<title>API docs</title>
</head>
<body>
<h1>Docs for URL shorter API</h1>
{% if apikey %}
<p>You API key is: {{apikey}}</p>
{% endif %}
<h3>Make a request</h3>
<p>The usage of the API is very simple, you have to make a push request to {{domain}}/user/api which have to include the folowing Arguments:</p>
<ul>
<li>short: the short URL you want to get. example: {{domain}}/example</li>
<li>long: the long URL you want to short</li>
<li>qr: if you add this parameter you will get an base64 encoded QR code image</li>
<li>apikey: you can add this argument, if you want to assign this link to your account.</li>
</ul>
<p>example API call with curl: <i>curl -d "apikey={{apikey}}&short={{domain}}/example&long=http://example.com" -X POST {{url_scheme}}://{{domain}}/user/api</i>
<h3>Responses from Server</h3>
<p>The response from the server is always made in json format it includes the following arguments:</p>
<ul>
<li>status: The status code of the reponse. Down there is a table with the posible response codes</li>
<li>message: This argument will do the same like the status code, but it is written out, for reading by human.</li>
<li>qr: If you enabled the QR code this will include a QR code of the shorten link as base64 coded jpeg image</li>
</ul>
<h4>Response codes:</h4>
<table>
<tr>
<th>Code</th>
<th>Meaning</th>
</tr>
<tr>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>1</td>
<td>The short URL argument is missing</td>
</tr>
<tr>
<td>2</td>
<td>The long URL is missing.</td>
</tr>
<tr>
<td>3</td>
<td>The doamin for the short URL is not in the list of allowed domains</td>
</tr>
<tr>
<td>4</td>
<td>The short URL is already taken.</td>
</tr>
</table>
<h2>Preview image</h2>
<p>Please paste your base64 image here: <input type="text" id="base64Input"> <button onclick="showBase64Image();">show</button></p>
<p style="font-size: 13px;">(this will not work very well in google Chrome)</p>
<img id="base64Image">
<script>
function showBase64Image(){
document.getElementById("base64Image").src = document.getElementById("base64Input").value;
}
</script>
</body>