JS / Docker example code

Welcome to the Akave Link API! This API wrapper enables seamless integration with Akave's decentralized storage network. Below, you’ll find quick setup steps, examples of how to use each API endpoint with JavaScript, and equivalent curl commands.

Github repo for reference : https://github.com/akave-ai/akavelink

Installing docker : https://docs.docker.com/engine/install/

Getting Started

Step 1: Pull the Docker Image

To start, pull the Akave Link Docker image:

docker pull akave/akavelink:latest

Step 2: Get a Wallet Address and Request Funds

  • Visit https://faucet.akave.ai to obtain a wallet address and add the Akave chain to MetaMask.

  • Request funds from the faucet to start experimenting with the Akave Link API.

Blockchain explorer : http://explorer.akave.ai

Run the container and specify the PRIVATE_KEY environment variable:

Node Address Public endpoint ( NODE_ADDRESS ) -> connect.akave.ai:5500

The API will now be running locally at http://localhost:8000.

Setting Up the JavaScript Wrapper

Here's a quick setup to interact with the Akave API using JavaScript:

Example Usage:

Each section below demonstrates API calls using this wrapper, alongside the curl equivalent.


Bucket Operations

1. Create a Bucket

Create a new storage bucket.

JavaScript Example:

curl Command:

2. List Buckets

Retrieve all existing buckets.

JavaScript Example:

curl Command:

3. View Bucket Details

Retrieve details of a specific bucket.

JavaScript Example:

curl Command:


File Operations

1. List Files in a Bucket

Retrieve a list of files within a bucket.

JavaScript Example:

curl Command:

2. Get File Info

Fetch metadata about a specific file.

JavaScript Example:

curl Command:

3. Upload a File

Upload a file to a bucket.

Make sure the minimum file size is 127 bytes! Keep max size to test at 100MB

JavaScript Example (using FormData):

curl Command:

4. Download a File

Download a file from a bucket.

JavaScript Example:

You can download the file directly in your browser or provide a download url with a public hosted API by using: http(s)://ip-or-dns-name/buckets/:BucketName/files/:FileName/download

curl Command:

Output file extention should be the same as the requested file.


Error Handling

All endpoints return errors in the following format:

Ensure you handle these responses in your code to capture and process errors effectively.

Good luck with your hackathon, and have fun building with Akave’s decentralized storage API!

Last updated