Normally Pleasant Mixture

    @decooio/sdk
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.5 • Public • Published

    Decoo SDK

    Official JavaScript SDK for Decoo.

    Installation

    npm install --save @decooio/sdk

    or,

    yarn add @decooio/sdk

    Usage

    import * as fs from "fs";
    
    const decooSdk = require('@decooio/sdk');
    
    // List available endpoints
    const decooEndpoints = await decooSdk.listEndpoints({
      zone: "cn", // default 'cn'
      jwt: "********"
    });
    
    // Get Ipfs CID of local file
    const decooUtils = decooSdk.utils;
    const localFileHash = await decooUtils.getFileHash(fs.createReadStream('/Some/Local/File/Path'));
    console.log(localFileHash);
    
    // Connect to an endpoint, and pin local file
    const decooClient = decooSdk.create({
      zone: "cn", // default 'cn'
      url: decooEndpoints[0].apiHost,
      jwt: "********",
      privateKey: "********"
    });
    
    // pinFile 
    const file = fs.createReadStream('/Some/Local/File/Path/name.txt')
    const addedFileHash = await decooClient.pinFile(file);
    console.log(addedFileHash);
    
    // you can pin string as file
    const addedFileHash = await decooClient.pinFile("Decoo, the Entrance to Web 3.0");
    console.log(addedFileHash);
    
    // pinByHash
    const byHash = await decooClient.pingByHash('Qmalksjkjfkaklsjdkf');
    console.log(byHash)

    Install

    npm i @decooio/sdk

    DownloadsWeekly Downloads

    5

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    1.89 MB

    Total Files

    33

    Last publish

    Collaborators

    • gavfu