open-index/open-npm huggingface dataset:
npm package: @fleekhq/sdk
Description: Fleek SDK makes easier interact with Fleek APIs and Internet Computer.
Latest version: 1.0.0-alpha.10
Deprecated: We’ve upgraded! The deprecated Fleek Storage SDK is now part of our all-new Fleek Platform SDK, which brings enhanced performance, new features, and broader support for all your development needs. Head to https://www.npmjs.com/package/@fleek-platform/sdk to get started, or visit https://fleek.xyz/docs to learn even more.

# 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.

```bash
npm install @fleekhq/sdk
```

It can also be installed through yarn.

```bash
yarn add @fleekhq/sdk
```

## Importing

The SDK can be imported using an import statement.

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

The SDK can also be imported using a require.

```js
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.

```ts
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.

```js
const ipfs = sdk.ipfs();
```

### Uploading data

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

## Asset Storage

### assets()

Returns an instance of the IC storage client

```js
const assetStorage = sdk.assets();
```

### uploading data

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

### assets().get()

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

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

### assets().listAll()

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

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

### assets().list()

```js
// 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.