The Capsule SDK is a comprehensive toolkit designed to interact with the Arweave network, facilitating file and folder management within a decentralized file system. It leverages Arweave's permanent storage capabilities to offer a robust solution for managing drives, folders, and files in a secure and immutable manner.
To use the Capsule SDK in your project, you need to install it via npm or yarn. Ensure you have Node.js installed in your environment before proceeding.
npm install capsule-js
or
yarn add capsule-js
The SDK is structured around several key services and models that interact with the Arweave network:
-
Capsule: The main entry point for using the SDK. It initializes the necessary services with provided configuration.
-
Services:
- DriveService: Manages operations related to drives such as creation, retrieval, and modification.
- FolderService: Handles folder-related operations including creation and listing of folder contents.
- FileService: Provides functionality to manage files, including uploading and downloading.
-
Models:
- Drive: Represents a drive entity on the Arweave network.
- Folder: Represents a folder within a drive.
- File: Represents a file within a folder.
-
Utilities:
- Crypto: Provides encryption and decryption functionalities for private drives and files.
- ArFSApi: Handles API calls to the Arweave network.
Below is a simple example demonstrating how to initialize the SDK and create a new drive:
import { Capsule } from 'capsule-js'
const capsule = new Capsule({ wallet: 'use_wallet', appName: 'arfs-js-drive' })
const drive = await capsule.drive.create('My Drive', { visibility: 'public' })
Below is a simple example demonstrating how to initialize the SDK and create a new folder:
import { Capsule } from 'capsule-js'
const capsule = new Capsule({ wallet: 'use_wallet', appName: 'arfs-js-drive' })
const folder = await capsule.folder.create('My Folder', {
driveId: '<driveId>',
parentFolderId: '<parentFolderId>',
visibility: 'public'
})
Below is a simple example demonstrating how to initialize the SDK and create a new file:
import { Capsule } from 'capsule-js'
const capsule = new Capsule({ wallet: 'use_wallet', appName: 'arfs-js-drive' })
const file = await capsule.file.create({
name: 'My File',
size: 1024,
dataContentType: 'text/plain',
driveId: '<driveId>',
parentFolderId: '<parentFolderId>',
file: fileBuffer,
visibility: 'public'
})
The SDK can be configured with the following options:
- gateway: URL to the Arweave gateway.
- wallet: Path or object representing the Arweave wallet.
- appName: Optional. Name of the application using the SDK.
Detailed API documentation is available for all classes and methods provided by the SDK. This includes parameters, return types, and descriptions of each function.
Contributions to the Capsule SDK are welcome. Please refer to the project's GitHub repository to submit issues or pull requests.
The SDK is licensed under the ISC license, allowing for free and open usage in both personal and commercial projects.
This documentation provides a high-level overview and starting points for integrating the Capsule SDK into your projects. For more detailed information, refer to the source code and further documentation in the SDK's repository.