akave-client

0.5.0 • Public • Published

Akave Client Library

Overview

Akave is a decentralized protocol for managing on-chain data lakes. This JavaScript library provides an easy-to-use interface for interacting with the Akave Link API.

Installation

npm install akave-client

Quick Start

Importing the Library

import akave, { Akave, createAkaveInstance } from 'akave-client';

Configuration

Set the Akave URL via environment variable:

AKAVE_BASE_URL=https://your-akave-endpoint.com

API Methods

Creating a Bucket

// Create a new bucket
const bucket = await akave.createBucket('my-new-bucket');
console.log(bucket.ID); // Bucket ID

Listing Buckets

// Get all buckets
const buckets = await akave.listBuckets();
buckets.forEach(bucket => {
  console.log(bucket.ID, bucket.CreatedAt);
});

File Operations

Upload a File

// Upload a file to a specific bucket
const fs = require('fs');
const file = fs.createReadStream('/path/to/file');
const uploadedFile = await akave.uploadFile('bucket-id', file);
console.log(uploadedFile.RootCID);

List Files in a Bucket

// Get all files in a bucket
const files = await akave.listFiles('bucket-id');
files.forEach(file => {
  console.log(file.Name, file.Size);
});

Download a File

// Download a specific file
const fileBlob = await akave.downloadFile('bucket-id', 'filename');

Get File URL

// Get download URL for a file
const fileUrl = await akave.getFileURL('bucket-id', 'filename');
console.log(fileUrl);

Get All File URLs in a Bucket

// Get URLs for all files in a bucket
const allFileUrls = await akave.getAllFileURLs('bucket-id');

Advanced Usage

// Creating a custom Akave instance
const customAkave = new Akave('https://custom-endpoint.com');
const bucket = await customAkave.createBucket('custom-bucket');

Error Handling

try {
  await akave.createBucket('my-bucket');
} catch (error) {
  console.error('Failed to create bucket:', error.message);
}

Environment Variables

  • AKAVE_BASE_URL: Base URL for the Akave Link API

Notes

  • All methods return Promises
  • File upload requires a ReadStream

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.5.02latest

Version History

VersionDownloads (Last 7 Days)Published
0.5.02
0.4.03
0.3.01
0.2.01
0.1.00

Package Sidebar

Install

npm i akave-client

Weekly Downloads

7

Version

0.5.0

License

MIT

Unpacked Size

212 kB

Total Files

22

Last publish

Collaborators

  • mainkt