/RSS3-SDK-for-JavaScript

JavaScript SDK for RSS3-Hub

Primary LanguageTypeScript

RSS3 SDK JavaScript

JavaScript SDK for RSS3-Hub

Quick Start

Install

npm install rss3 --save

or

yarn add rss3

Demo

import RSS3 from 'rss3';

const rss3 = new RSS3({
    endpoint: 'https://rss3-hub-playground-6raed.ondigitalocean.app',
    privateKey:
        '0x47e18d6c386898b424025cd9db446f779ef24ad33a26c499c87bb3d9372540ba',
});

await rss3.profilePatch({
    name: 'RSS3',
    avatar: 'https://cloudflare-ipfs.com/ipfs/QmZWWSspbyFtWpLZtoAK35AjEYK75woNawqLgKC4DRpqxu',
    bio: 'RSS3 is an open protocol designed for content and social networks in the Web 3.0 era.',
});
await rss3.itemPost({
    title: 'Hello RSS3',
    summary:
        'RSS3 is an open protocol designed for content and social networks in the Web 3.0 era.',
});
await rss3.itemsPatch(
    {
        id: rss3.address + '-item-0',
        title: 'Hi RSS3',
    },
    rss3.address,
);

await rss3.syncFile();

API

Initialization

const persona = new RSS3({
    endpoint: 'https://rss3-hub.example',
    privateKey: '0x.....',
    callback: (persona) => {
        console.log(persona);
    },
});

Options:

config: {
    endpoint: string; // RSS3 Hub Address
    privateKey?: string; // Persona's private key, a new persona will be created if it is empty
    callback?: (persona) => void; // Initialization callback
}

ProfilePatch

await rss3.profilePatch({
    name: 'RSS3',
    avatar: 'https://cloudflare-ipfs.com/ipfs/QmZWWSspbyFtWpLZtoAK35AjEYK75woNawqLgKC4DRpqxu',
    bio: 'RSS3 is an open protocol designed for content and social networks in the Web 3.0 era.',
});

Options:

profile: {
    name?: string;
    avatar?: ThirdPartyAddress;
    bio?: string;
    tags?: string[];
}

ItemPost

await rss3.itemPost({
    title: 'Hello RSS3',
    summary:
        'RSS3 is an open protocol designed for content and social networks in the Web 3.0 era.',
});

Options:

item: {
    authors?: RSS3ID[];
    title?: string;
    summary?: string;
    tags?: string[];

    type?: string;
    upstream?: RSS3ItemID;

    contents?: {
        address: ThirdPartyAddress;
        mime_type: string;
        name?: string;
        tags?: string[];
        size_in_bytes?: string;
        duration_in_seconds?: string;
    }[];
}

ItemsPatch

await rss3.itemsPatch(
    {
        id: rss3.address + '-item-0',
        title: 'Hi RSS3',
    },
    rss3.address,
);

Options:

item: {
    id: string;
    authors?: RSS3ID[];
    title?: string;
    summary?: string;
    tags?: string[];

    type?: string;
    upstream?: RSS3ItemID;

    contents?: {
        address: ThirdPartyAddress;
        mime_type: string;
        name?: string;
        tags?: string[];
        size_in_bytes?: string;
        duration_in_seconds?: string;
    }[];
}
fileID: string;

SyncFile

await rss3.syncFile();

GetFile

await rss3.getFile(rss3.address.items_next);

Options:

fileID: string;

DeleteFile

await rss3.deleteFile(rss3.address);

Options:

personaID: string;