0.1.4 • Published 2 years ago

public-square-api v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

See it on NPM! License

public-square-api

an api for the public-square Protocol

Install

npm install public-square-api

Examples

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

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.1.4

2 years ago

0.0.5

2 years ago

0.1.3

2 years ago

0.0.4

3 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago