Socket
Socket
Sign inDemoInstall

@fleekhq/sdk

Package Overview
Dependencies
39
Maintainers
8
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @fleekhq/sdk

Fleek SDK makes easier interact with Fleek APIs and Internet Computer.


Version published
Maintainers
8
Install size
5.34 MB
Created

Readme

Source

Fleek SDK

Fleek SDK is a javascript library that makes easier to interact with Fleek APIs and Internet Computer.

Installation

Use the npm package manager to install it.

npm install @fleekhq/sdk

It can also be installed through yarn.

yarn add @fleekhq/sdk

Importing

The SDK can be imported using an import statement.

import { Fleek } from '@fleekhq/sdk';

The SDK can also be imported using a require.

const { Fleek } = require('@fleekhq/sdk');

Usage

You can initialise instance only with apiKey, but if you want to leverage asset canister you also need to provide assetCanisterId property.

import { Fleek } from '@fleekhq/sdk';

const sdk = new Fleek({
  apiKey: 'your-api-key', // your Fleek API Key
  assetCanisterId: 'your-asset-canister-id',
});

Methods

IPFS Storage

ipfs()

Returns an instance of the IPFS client. For more information check out https://www.npmjs.com/package/ipfs-http-client.

const ipfs = sdk.ipfs();

Uploading data

await sdk.ipfs().add(...);

Asset Storage

assets()

Returns an instance of the IC storage client

const assetStorage = sdk.assets();

uploading data

await sdk.assets().store(key, data);
await sdk.assets().storeJson(key, { some: 'value' });

assets().get()

const asset = await sdk.assets().get(key);

Returns the asset with the provided key. Returns null if not found.

assets().listAll()

const assets = await sdk.assets().listAll();

Returns a list of all assets. Returns [] if none.

assets().list()

// list images for a specific user
const prefix = `images/${uid}`;
const assets = await sdk.assets().list(prefix);

Returns a list of all assets whose keys start with the provided prefix. Returns [] if none.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

FAQs

Last updated on 17 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc