@fleekhq/sdk v1.0.0-alpha.10
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/sdkIt can also be installed through yarn.
yarn add @fleekhq/sdkImporting
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.
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago