# public-square-api

> an api for the public-square Tribus

Latest version **0.1.4** (published 2021-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install public-square-api
pnpm add public-square-api
yarn add public-square-api
bun add public-square-api
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2021-11-23 |
| First published | 2021-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 40.2 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | charmful0x |
| Maintainers | charmful0x |
| Keywords | arweave, social-network, web3 |

## Links

- npm: https://www.npmjs.com/package/public-square-api
- Repository: https://github.com/decentldotland/public-square-api
- Homepage: https://github.com/decentldotland/public-square-api#readme
- Issues: https://github.com/decentldotland/public-square-api/issues
- npm.io page: https://npm.io/package/public-square-api

## Dependencies (4)

- [axios](https://npm.io/package/axios.md) ^0.24.0
- [arweave](https://npm.io/package/arweave.md) ^1.10.18
- [base64url](https://npm.io/package/base64url.md) ^3.0.1
- [node-fetch](https://npm.io/package/node-fetch.md) ^3.0.0

## Recent versions

- 0.1.4 (latest) — 2021-11-23
- 0.1.3 — 2021-11-21
- 0.1.2 — 2021-11-19
- 0.1.1 — 2021-11-19
- 0.1.0 — 2021-11-18
- 0.0.9 — 2021-11-17
- 0.0.8 — 2021-11-16
- 0.0.7 — 2021-11-15
- 0.0.6 — 2021-11-13
- 0.0.5 — 2021-11-12
- 0.0.4 — 2021-11-11
- 0.0.3 — 2021-11-02
- 0.0.2 — 2021-11-02
- 0.0.1 — 2021-11-02

## README

<p align="center">
  <a href="https://decent.land">
    <img src="./img/logo25.png" height="124">
  </a>
  <h3 align="center"><code>@decentdotland/public-square-api</code></h3>
</p>


[![See it on NPM!](https://img.shields.io/npm/v/public-square-api?style=for-the-badge)](https://www.npmjs.com/package/public-square-api)
[![License](https://img.shields.io/apm/l/vim-mode?style=for-the-badge)]()


# 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
```javascript
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
```javascript
import { getLazyFeed } from "public-square-api"

async function loadTribusFeed() {
    const feed = await getLazyFeed();

    return feed;
}

```

returns an array of posts metadata objects:
```js
[
  {
    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:
```js
// 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

---
_Source: https://npm.io/package/public-square-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
