Skip to content
Snippets Groups Projects
apiDocs.html 2.03 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jonas Leder's avatar
    Jonas Leder committed
    <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>
    </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>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></p>
    
        <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>
        </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>
    </body>