Skip to content

A selection of Mastodon API methods implemented in Node.js

License

Notifications You must be signed in to change notification settings

pasimako/mastodon-api

Repository files navigation

mastodon-api

A lightweight Node.js client for interacting with Mastodon instances.

This library implements a curated set of Mastodon API methods, allowing you to authenticate, fetch timelines, post statuses, and manage accounts.

Requirements

  • Node v20

Install dependencies

$ npm install

Run tests

$ npm test

Package Locally

To create a tarball that you can install in another project:

$ npm pack

Then in another Node.js project:

$ npm install mastodon-api-x.x.x.tgz

Quick Usage

In your package.json, reference the local tarball:

"dependencies": {
  ...
  "mastodon-api": "file:./lib/mastodon-api-x.x.x.tgz"
  ...
},

Import the MastodonAPI class and create a new client by providing your Mastodon access token and instance URL (for example, https://mastodon.social).

import { MastodonAPI } from "mastodon-api";

const api = new MastodonAPI({
  accessToken,
  instanceURL,
});

// Confirm access token is valid
const { id, username, followers_count, following_count } =
    await api.apps.verifyCredentials();

This request returns information about the authenticated account and confirms that the provided access token has the required permissions.

License

MIT

About

A selection of Mastodon API methods implemented in Node.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published