JSPM

  • Created
  • Published
  • Downloads 19727
  • Score
    100M100P100Q150578F
  • License (Apache-2.0 AND MIT)

nft.storage client

Package Exports

  • nft.storage
  • nft.storage/src/platform.js

Readme

nft.storage

ci package styled with prettier size deps codecov

A client library for the https://nft.storage/ service. It provides a convenient interface for working with the Raw HTTP API from a web browser or Node.js and comes bundled with TS for out-of-the box type inference and better IntelliSense.

Install

Install the package using npm

npm install nft.storage

Or yarn

yarn add nft.storage

Usage

First, obtain an API token from https://nft.storage and use it in place of API_TOKEN below:

import { NFTStorage, File } from 'nft.storage'
const client = new NFTStorage({ token: API_TOKEN })

const metadata = await client.store({
  name: 'Pinpie',
  description: 'Pin is not delicious beef!',
  image: new File(
    [
      /* data */
    ],
    'pinpie.jpg',
    { type: 'image/jpg' }
  ),
})
console.log(metadata.url)
// ipfs://bafyreib4pff766vhpbxbhjbqqnsh5emeznvujayjj4z2iu533cprgbz23m/metadata.json

For more examples please see the API documentation or the examples directory.