1.1.3 • Published 1 month ago

mastodonclient v1.1.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 month ago

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

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.

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:

const mc = new m.MastodonClient(config)

This can be used to post toots:

// message, visibility, content warning 
await mc.post('Who\'s there?', 'public', 'Knock knock')

fetch your timeline:

const timeline = await mc.home()

or do any other request:

const result = await mc.request({
  method: 'get',
  url: '/api/v1/timelines/home',
  params: {
    limit: 5
  }
})

See the Mastodon API reference.

1.1.3

1 month ago

1.1.2

6 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago