npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pinata-sdk

v0.1.7

Published

Unofficial SDK for [Pinata](https://pinata.cloud), implemented in ReasonML and compiled to Javascript.

Downloads

202

Readme

Pinata SDK

Unofficial SDK for Pinata, implemented in ReasonML and compiled to Javascript.

What is Pinata?

Pinning service that improves your IPFS experience by deploying the underlying infrastructure so you don't have to!

In order to use some of the SDK's features, you'll have to sign up with Pinata to obtain your API keys. To learn more about Pinata check out the getting started guide.

Installing

Install the package - it includes both the javascript & reason versions.

npm i --save pinata-sdk

If you're using ReasonML, add this to your bsconfig.json:

"bs-dependencies": [
    "pinata-sdk"  
],

Quick start 👩‍💻

Following examples demonstrates pinning an IPFS hash on Pinata, using the SDK. In order to do so, you need to authenticate yourself with Pinata API keys.

⚠️ For usage with Node.js, make sure to include the node-fetch polyfill.

ReasonML

open PinataSdk;
open PinataSdk.PinHashToIPFS;

let hash = "<your ipfs content hash>";
let apiKey = "<your api key>";
let privateApiKey = "<your private api key>";
let pinata = Pinata.configure(
  ~apiKey = apiKey,
  ~privateApiKey = privateApiKey,
  ()
);

pinata
  ->Pinata.pinHashToIPFS(~hash=hash)
    |> then_(result => {
      Js.log("Content pinned successfully" ++ result->ipfsHashGet)
      Js.Promise.resolve(result);
    })

TypeScript

import * as Pinata from 'pinata-sdk';
const apiKey = "<your api key>";
const privateApiKey = "<your private api key>";
const hash = "<your ipfs content hash>";
const pinata: Pinata.PinataConfig = Pinata.configure(apiKey, privateApiKey);

(async function() {
    try {
        const result: Pinata.PinHashToIPFSResponseJS = await Pinata.pinHashToIPFS(
            pinata,
            hash
        );
        console.log("Content pinned successfully", result.ipfsHash);
    } catch (err) {
        console.error("Content was not pinned", err);
    }
})();

Javascript

const Pinata = require('pinata-sdk');
const apiKey = "<your api key>";
const privateApiKey = "<your private api key>";
const hash = "<your ipfs content hash>";
const pinata = Pinata.configure(apiKey, privateApiKey);

(async function() {
    try {
        const result = await Pinata.pinHashToIPFS(
            pinata,
            hash
        );
        console.log("Content pinned successfully", result.ipfsHash);
    } catch (err) {
        console.error("Content was not pinned", err);
    }
})();

API 🕹

Available methods of the SDK, for usage examples see the quick start guide or the examples section.

configure (~apiKey: string, ~privateApiKey: string, ~apiURL: string = apiURL): pinataConfig
  • apiKey your api key from pinata
  • privateApiKey your private api key from pinata
  • apiURL optional, default value https://api.pinata.cloud
pinHashToIPFS (config: pinataConfig, ~hash: ipfsHash): Promise.t(pinHashToIPFSResponseJS)
  • config SDK configuration created via configure()
  • hash IPFS content hash to be pinned

Examples 🤓

You can find the usage examples in the examples folder.

🐳 Optionally you can start the development container described in the contributing section, in order to run the examples smoothly.

Make sure to:

  1. npm i before running each example.
  2. Update your Pinata API credentials in examples/**/credentials.js
  3. Update the IPFS hash you want to pin - usually a string in the example's source files.

Each example can be run using npm start.

Some examples might contain additional README.md to help you understand the details.

Contributing 🔧

PinataSDK is developed & built trough docker, to start contributing, you'll have to setup docker for your platform first.

Editor support for ReasonML works well with VSCode's OCaml and Reason IDE

Development container

Everything you need to contribute to PinataSDK happens inside the development container

# Build an image for our dev container
make build-image
# Launch the container with an interactive bash session
make bash

Available commands

List of available commands can be found in package.json.

# Install dependencies
npm install

# Rebuild on every file change
npm run start

# Build the SDK
npm run build

# Cleans build artifacts
npm run clean

License 📃

PinataSDK is available under the MIT License

Powered by

Credits 😎

Pinata SDK is created and maintained by Matej Sima.

Special thanks to the Pinata team for such an awesome service!