JavaScript SDK for RSS3-Hub
Install
npm install rss3 --save
or
yarn add rss3
import RSS3 from 'rss3';
or
const RSS3 = require('rss3').default;
API
Initialization
new RSS3(options: {
endpoint: string;
privateKey?: string;
})
Example:
const rss3 = new RSS3({
endpoint: 'https://rss3-hub-playground-6raed.ondigitalocean.app',
privateKey: '0x47e18d6c386898b424025cd9db446f779ef24ad33a26c499c87bb3d9372540ba',
});
Persona
persona.privateKey
persona.privateKey: string
Example:
const privateKey = rss3.persona.privateKey;
persona.id
persona.id: string
Example:
const id = rss3.persona.id;
persona.sync()
Please note that changes will only be synced to the node after persona.sync()
is successfully executed
persona.sync(): string[]
Example:
const changedFiles = rss3.persona.sync();
persona.raw()
persona.raw(fileID: string = persona.id): Promise<RSS3IContent>
Example:
const file = await rss3.persona.raw();
Profile
profile.get()
profile.get(personaID: string = persona.id): Promise<RSS3Profile>
Example:
const profile = rss3.profile.get();
profile.patch()
profile.patch(profile: RSS3Profile): Promise<RSS3Profile>
Example:
const newProfile = await rss3.profile.patch({
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.',
});
Items
items.get()
items.get(fileID: string = persona.id): Promise<{
items: RSS3Item[],
items_next?: string,
}>
Example:
const list1 = await rss3.items.get();
const items1 = list1.items;
const list2 = await rss3.items.get(list1.items_next);
const items2 = list2.items;
Item
item.get
item.get(itemID: string): Promise<RSS3Item>
Example:
const item = await rss3.item.get('0x47e18d6c386898b424025cd9db446f779ef24ad33a26c499c87bb3d9372540ba-item-0');
item.post
item.post(item: RSS3ItemInput): Promise<RSS3ItemInput>
Example:
const item = await rss3.item.post({
title: 'Hello RSS3',
summary: 'RSS3 is an open protocol designed for content and social networks in the Web 3.0 era.',
});
item.patch
item.patch(item: RSS3ItemInput): Promise<RSS3ItemInput>
Example:
const newItem = await rss3.item.patch({
title: 'Hi RSS3',
});
Links
links.get
links.get(fileID: string): Promise<RSS3Links[]>;
links.get(fileID: string, type: string): Promise<RSS3Links>;
Example:
const following = await rss3.links.get(rss3.persona.id, 'following');
links.post
links.post(links: RSS3LinksInput): Promise<RSS3Links>
Example:
const following = await rss3.links.post({
type: 'following',
list: ['0xd0B85A7bB6B602f63B020256654cBE73A753DFC4'],
});
links.delete
links.delete(type: string): Promise<RSS3Links>
Example:
const following = await rss3.links.delete('following');
links.patch
links.patch(links: RSS3LinksInput): Promise<RSS3Links>
Example:
const following = await rss3.links.patch({
type: 'following',
tags: ['test'],
list: ['0xd0B85A7bB6B602f63B020256654cBE73A753DFC4', '0xC8b960D09C0078c18Dcbe7eB9AB9d816BcCa8944'],
});
Link
link.post
link.post(type: string, personaID: string): Promise<RSS3Links>
Example:
const following = await rss3.link.post('following', '0xd0B85A7bB6B602f63B020256654cBE73A753DFC4');
link.delete
link.delete(type: string, personaID: string): Promise<RSS3Links>
Example:
const following = await rss3.link.delete('following', '0xd0B85A7bB6B602f63B020256654cBE73A753DFC4');
Backlinks
backlinks.get
backlinks.get(personaID?: string): Promise<RSS3Backlink[]>
backlinks.get(personaID: string, type: string): Promise<string[]>
Example:
const followers = await rss3.backlinks.get(rss3.persona.id, 'following');