Package Exports
- public-square-api
- public-square-api/src/api.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (public-square-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@decentdotland/public-square-api
public-square-api
an api for the public-square Protocol
Install
npm install public-square-apiExamples
I) get public-square's feed
method 1: data decoded from the TX's data property
import { getFeed } from "public-square-api"
async function loadTribusFeed() {
const feed = await getFeed();
return feed;
}
method 2 (LazyAccess): data decoded from the TX's lazyAcess tag
import { getLazyFeed } from "public-square-api"
async function loadTribusFeed() {
const feed = await getLazyFeed();
return feed;
}
returns an array of posts metadata objects:
[
{
pid: 'JzK-8crzmr76Uj7SkiP_XhD6Ig-B8N6OsSSSmOIL3g8',
poster: 'vZY2XY1RD9HIfWi8ift-1_DnHLDadZMWrufSh-_rKF0',
timestamp: 1637349516,
data: { text: 'stonks 📈📈', media: [] }
},
{
pid: 'RfE5vkrluExB7Q-JgPFEr6PbbcWcmtq5emF64QkxN5w',
poster: 'vZY2XY1RD9HIfWi8ift-1_DnHLDadZMWrufSh-_rKF0',
timestamp: 1637349516,
data: { text: 'welcome to the PublicSquare! 👋', media: [] }
},
...
]
II) get posts TXIDs per address
code:
// assuming the code is async-await
const address = "...";
const postsTxs = await getPostsOf(address);
output:
The same output of getFeed() but filtered for a single address.
License
This project is licensed under the MIT license