New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mastodonclient

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mastodonclient

Simple Mastodon client

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

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.

import * as mastonclient from 'mastodonclient'
const config = await mastonclient.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 mastonclient.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.

Keywords

Mastodon

FAQs

Package last updated on 22 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts