Skip to content

4ortytwo/filebase-js

 
 

Repository files navigation

filebase-js

ci package styled with prettier size codecov

A client library for the https://filebase.com/ 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 filebase-js

Or yarn

yarn add filebase-js

Usage

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

import { FilebaseStorage, File } from 'filebase-js'
const client = new FilebaseStorage({ 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:https://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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 77.4%
  • TypeScript 22.6%