Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glynnbird/mastodonclient
A minimal Mastodon client
https://github.com/glynnbird/mastodonclient
Last synced: about 1 month ago
JSON representation
A minimal Mastodon client
- Host: GitHub
- URL: https://github.com/glynnbird/mastodonclient
- Owner: glynnbird
- Created: 2022-11-18T11:11:23.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T12:56:45.000Z (4 months ago)
- Last Synced: 2024-09-29T19:06:33.763Z (about 2 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mastodonclient
Minimal Mastodon client for my purposes. Does the OAuth dance and allows toots to be posted, home timeline to be fetched or generic API call to be made
## Installation
```sh
npm install --save mastodonclient
```## Usage
One time only, you need to do the OAuth dance. This is an interactive process where you'll need to enter your Mastodon hostname, visit a URL and enter the code displayed at that URL back into the command line prompt.
```js
const m = require('mastodonclient')
const config = await m.auth()
console.log(config)
```The `config` is a JS object that contains all the details required to authenticate you to make Mastodon API calls. Stash this away in a file somewhere.
If we have a `config` object we can instantiate the `MastodonClient` itself:
```js
const mc = new m.MastodonClient(config)
```This can be used to post toots:
```js
// message, visibility, content warning
await mc.post('Who\'s there?', 'public', 'Knock knock')
```fetch your timeline:
```js
const timeline = await mc.home()
```or do any other request:
```js
const result = await mc.request({
method: 'get',
url: '/api/v1/timelines/home',
params: {
limit: 5
}
})
```See the [Mastodon API reference](https://docs.joinmastodon.org/methods/statuses/).