Socket
Socket
Sign inDemoInstall

nft.storage

Package Overview
Dependencies
Maintainers
0
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nft.storage

A client library for the https://nft.storage/ service. It provides a convenient interface for working with the HTTP API from a web browser or Node.js


Version published
Maintainers
0
Created
Source

nft.storage

Notice: Uploads have been decommissioned, and upload functionality in this package no longer functions, even with a valid API key. Please visit the product page to learn more and find a new hot storage provider for uploading new assets.

ci package styled with prettier size 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' })

async function main() {
  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
}

main()

The client uses ESM modules. If running from Node.js, either name your script index.mjs or name it index.js and use npm init to create a new package.json file in your project directory, adding "type": "module", to it.

Run the script:

node index.mjs # or index.js

For more examples please see the API documentation or the examples directory in the project repository, which contains sample projects for both browsers and Node.js.

FAQs

Package last updated on 01 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc