<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="TempFile • API">
    <link rel="fluid-icon" href="/media/favicon.ico" title="TempFile • API">
    <meta name="twitter:image:src" content="/media/favicon.ico">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="TempFile/API">
    <meta name="twitter:description" content="A website that temporarily stores files to a chosen date.">
    <meta property="og:image" content="/media/favicon.ico">
    <meta property="og:site_name" content="TempFile">
    <meta property="og:type" content="object">
    <meta property="og:title" content="TempFile • API">
    <meta property="og:url" content="/api">
    <meta property="og:description" content="A website that temporarily stores files to a chosen date.">
    <title>TempFile • API</title>
    <%- include('include/head.ejs') %> 
    <link rel="stylesheet" href="/css/api.css">
    <script src="/js/api.js"></script>
</head>

<body>
    <%- include('include/header.ejs') %>
    <!--sse-->
    <div id="content">
        <h1 id="using-requests">Using Requests</h1>
        <p>
            Requests are done on the api path (/api/files/). After each request, a json response will be returned
            containing an 'ok' key to signify if it was successful or not. For example after a successful post
            request to upload a file, the output should look something like this: <br />
            <code>{"ok":true,"link":"https://tempfile.site/files/filename.png"}</code>
        </p>
        <h2 id="getting-a-file">Getting a file</h2>
        <p>Use a get request to get a file eg.</p>
        <pre><code class="bash language-bash">curl -O http://tempfile.site/api/files/filename.png</code></pre>
        <p>If a file requires a password, send the password in a header with a pass key eg.</p>
        <pre><code class="bash language-bash">curl -O http://tempfile.site/api/files/filename.png -H "pass: the password"</code></pre>
        <h2 id="uploading-a-file">Uploading a file</h2>
        <p>Use a post request to upload files with the file and the expiry date / time, eg.
        </p>
        <pre><code class="bash language-bash">curl -F datetime=1m -F file=@/path/to/file.png http://tempfile.site/api/files</code></pre>
        <p>
            For the expiry date, you can either use a timestamp string or a number with a unit eg. <code>3m</code> for 3
            minutes, <code>1w</code> for a week, <code>1mo</code> for 1 month or <code>2002-05-19T:08:00.000Z</code> for
            my
            birthday (just make sure it's not in the past)
        </p>
        <p>To use a custom filename, use a form argument with a name parameter (<code>-F name=file-name</code>). Filenames should not have special characters that aren't url friendly, in other words, it should follow this pattern
            <code>[a-z0-9-_\.]</code>.
        </p>
        <p><strong>Other options:</strong></p>
        <pre><code class="yaml language-yaml">limit: Download limit, don't add this for unlimited. (-F limit=5). After this limit, file will be deleted

pass: Password protect the file. (-F pass="A password")

ipblacklist: An IP to blacklist from downloading file. (-F ipblacklist="69.80.31.225"). For more than one IP, use a comma as separator instead of setting another form (-F), eg. -F ipblacklist="68.80.31.225,50.90.30.222"

ipwhitelist: If added, file will only be downloaded from this IP. And as mentioned above, you can seperate by a command if more than one.

authkey: Without this key, you won't be able to delete the file if it was not posted from the same IP. If you don't give a custom authkey parameter, it will be gerenerated for you and returned alongside the file url in response</code></pre>
        <p><em>All options must be lowercase.</em></p>
        <h2 id="deleting-a-file">Deleting a file</h2>
        <p>To delete a file you'll need to send a delete request to the file eg.</p>
        <pre><code class="bash language-bash">curl -X DELETE http://tempfile.site/api/files/filename.png</code></pre>
        <p>
            You can delete the file if it was uploaded from the same IP address, otherwise you will need an auth key.
            You can find the auth key by clicking 'more' from the options on the website before uploading. <br />
            To delete the file with the auth key you must send the key from a header named "authkey" eg.
        </p>
        <pre><code class="bash language-bash">curl -X DELETE http://tempfile.site/api/files/filename.png -H "authkey: the key"</code></pre>
    </div>
    <!--/sse-->
</body>

</html>