tusk-mastodon
v2.5.0
Published
⚠️ DEPRECATED - Please use 'masto' package instead. Async Mastodon API client for node
Maintainers
Readme
⚠️ DEPRECATED - Tusk-Mastodon
🚨 This package is deprecated and no longer maintained
Tusk has been retired and discontinued. This repository is kept for reference purposes only.
Migration Guide
Please migrate to the masto package, which is actively maintained and offers more features:
npm install mastoLearn more: https://www.npmjs.com/package/masto
We thank everyone who used Tusk and wish you success with your migration.
Tusk-Mastodon
Mastodon API Client for node - forked from node-mastodon [abandoned]
Source on GitHub | Documentation
Notes
- I forked this project and fixed the obvious issues / updated the packages, and replaced
requestwithaxios. - I added tests using Bun.sh runtime and test environment.
- Introduced individual HTTP methods (get, post, put, etc.) alongside the generic request method.
If you find any bugs please open an issue and I will handle it as soon as I can. Thanks!
Installing
npm install tusk-mastodonUsage:
var Tusk = require("tusk-mastodon");
var T = new Tusk({
access_token: "...",
timeout_ms: 60 * 1000, // optional HTTP request timeout to apply to all requests.
api_url: "https://mastodon.social/api/v1/", // optional, defaults to https://mastodon.social/api/v1/
});Tusk API:
var T = new Tusk(config)
Create a Tusk instance that can be used to make requests to Mastodon's APIs. Only supports oauth2 access tokens (no username/password auth) for security reasons.
I advise that you use the oauth package to get the user's access_token. More information about how to do that is on the node-mastodon wiki.
You'll need to register your app on Mastodon first as well.
If authenticating with user context, config should be an object of the form:
{
access_token: '...'
}T.get(path, [params], callback)
GET any of the REST API endpoints.
path
The endpoint to hit.
params
(Optional) parameters for the request.
callback
function (err, data, response)
datais the parsed data received from Mastodon.responseis the http.IncomingMessage received from Mastodon.
T.post(path, [params], callback)
POST any of the REST API endpoints. Same usage as T.get().
T.getAuth()
Get the client's authentication tokens.
T.setAuth(tokens)
Update the client's authentication tokens.
Tests
- Install Bun
curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL- Run Tests
bun testExamples
Reading the home timeline
T.get("timelines/home", {}).then((resp) => console.log(resp.data));Upload an image and attach it to a toot
var id;
T.post("media", { file: fs.createReadStream("path/to/image.png") }).then((resp) => {
id = resp.data.id;
T.post("statuses", { status: "#selfie", media_ids: [id] });
});