0.0.1-14 • Published 10 months ago

@uniblock/pinata v0.0.1-14

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

uniblock-pinata-sdk

This is a wrapper sdk for the Pinata sdk.

Before you begin, get a pinata api key using these steps.

Setup

Follow this step to add @uniblock/pinata to your repository

npm i @uniblock/pinata or yarn add @uniblock/pinata

General Overview

Pinata allows users to upload files, metadata and directories to IPFS. IPFS is a distributed system for storing and accessing files, websites, applications, and data. For more information about IPFS visit their documentation. After pinning a file/folder users get back a IPFS Hash which can be used with any of these gateways to access their uploaded files by appending the hash to the gateway url (eg. https://ipfs.io/ipfs/QmfZLApYD3EBZsXU1U7TwQFBpqNgXcxjkrCVYYoLtZANSM where https://ipfs.io/ipfs/ is the public gateway and QmfZLApYD3EBZsXU1U7TwQFBpqNgXcxjkrCVYYoLtZANSM is the hash).

Quick Start

Initialization

To initialize, pinata you have to provide your Uniblock API key which can be found on the dashboard. User may optionally provide their own pinata API key, this would allow them to avoid getting rate-limited from uniblock.

Note

Users have the option to either provide their own pinata key or rely on uniblock's key, although providing your own pinata key is recommended. If the key is not provided, @uniblock/pinata will default to uniblock's default key

import { initializePinata } from '@uniblock/pinata';

const pinataApiKey = 'YOUR_PINATA_API_KEY';
const pinataApiSecretKey = 'YOUR_PINATA_SECRET_KEY';
const uniblockApiKey = 'YOUR_UNIBLOCK_KEY';

const pinataWithOwnKeys = await initializePinata(
  uniblockApiKey,
  piniataApiKey,
  pinataApiSecretKey,
);

const pinata = await initializePinata(uniblockApiKey); //pinata keys are optional

PinFile

This method allows users to pin a file to IPFS

const pin = await pinata.pinFile(FILE_TO_PIN);
//pinata is the initialized pinata instance

PinFileAndMetaData

This method allows users to pin a file and metadata regarding the file

const pin = await pinata.pinFileAndMetaData(FILE, 'METADATA');
//pinata is the initialized pinata instance

Here metadata is any valid JSON string, an example JSON is listed below

 {
   "application": "MyApplication",
   "name": "OrdersProducts",
   "description": "Model containing data for Order and Products.",
   "version": "1.0",
   "lastUpdated": "2018-01-02T12:00:00+08:00",
}

PinDirectory

This method allows users to pin a directory to IPFS

const pin = await pinata.pinDirectory(FILES_TO_PIN);
//pinata is the initialized pinata instance

Retrieve

This method allows users to retrieve an image from its IPFS hash

const file = await pinata.retrieve('YOUR_HASH', 'PREFERRED_GATEWAY');

If PREFERRED_GATEWAY is not provided, @uniblock/pinata will use its default and backup gateways

0.0.1-14

10 months ago

0.0.1-13

10 months ago

0.0.1-15

10 months ago

0.0.1-12

12 months ago

0.0.1-11

1 year ago

0.0.1-10

1 year ago

0.0.1-9

1 year ago

0.0.1-8

1 year ago

0.0.1-3

1 year ago

0.0.1-2

1 year ago

0.0.1-1

1 year ago

0.0.1-7

1 year ago

0.0.1-6

1 year ago

0.0.1-5

1 year ago

0.0.1-4

1 year ago

0.0.1-0

1 year ago

1.0.1

1 year ago

1.0.0-2

1 year ago

1.0.0

1 year ago

1.0.0-1

1 year ago

1.0.0-0

1 year ago