a00.js
Usage

Usage

a00.js has 3 main methods. First, you need to initialize the A00 class with the API key.

You can get your API key from a00.app Settings (opens in a new tab).

import { A00 } from "a00.js";
 
const a00 = new A00("YOUR_API_KEY")

Uploading files

upload method returns the uploaded file's ID, CID, and metadata.

// Returns an object, which is needed for deleting & downloading files in future
const file = await a00.upload("./path/to/file");
 
/**
 * @returns {
 * id: string;
 *  cid: string;
 *  metadata: {
 *      name: string;
 *      size: number;
 *      extension: string
 *  };
 *  createdAt: Date;
 * }
*/

Downloading files

const content = await a00.get(file.id);

Then you can save the file

fs.writeFileSync(`./${file}.txt`, content);

Deleting files

Delete a specific file by its ID.

a00.delete(file.id);

Delete all files uploaded by user

a00.deleteAll();