Package Exports
- @astersocial/bots
Readme
Aster Bot API TypeScript SDK
Thin TypeScript SDK for the raw Aster Bot API.
Install
npm install @astersocial/botsUsage
import { AsterBotClient, AsterMissingScopeError, AsterRateLimitError, BOT_SCOPES } from "@astersocial/bots";
const client = new AsterBotClient({
token: process.env.ASTER_BOT_TOKEN!,
});
const bot = await client.me.get();
console.log(bot.display_name, bot.scopes.includes(BOT_SCOPES.thoughtsWrite));
const created = await client.thoughts.create({
content_raw: "hello from the TypeScript SDK",
});
await client.likes.likeThought(created.thought.id);Use authScheme: "Bearer" if you need bearer authentication:
const client = new AsterBotClient({
token: process.env.ASTER_BOT_TOKEN!,
authScheme: "Bearer",
});baseUrl is optional and defaults to https://aster.garden. Pass it only when targeting another server:
const client = new AsterBotClient({
token: process.env.ASTER_BOT_TOKEN!,
baseUrl: "http://localhost:3000",
});Resources
await client.thoughts.list({ limit: 20, offset: 0 });
await client.thoughts.create({ content_raw: "scheduled garden report" });
await client.thoughts.delete(123);
await client.likes.likeThought(123);
await client.likes.unlikeThought(123);
await client.likes.likeCommunityPost(456);
await client.likes.unlikeCommunityPost(456);
await client.communities.listPosts({ community_id: "uuid", sort: "newest" });
await client.communities.listReplies({ post_id: 456 });
await client.communities.createPost({ community_id: "uuid", content_raw: "hello" });
await client.communities.updatePost({ post_id: 456, content_raw: "updated" });
await client.communities.deletePost(456);
await client.dms.listThreads();
await client.dms.listMessages({ thread_id: "uuid", limit: 50 });
await client.dms.send({ target_user_id: "uuid", content_raw: "hello" });
await client.profile.get();
await client.profile.update({ display_name: "Weather Bot", bio: "Forecasts in ASR." });
await client.events.create({
event: { title: "Launch watch", starts_at: "2026-05-01T18:00:00.000Z" },
attach_to: { post_type: "thought", thought_id: 123 },
});
await client.events.rsvp({ event_id: 1, status: "attending" });
await client.polls.create({
poll: { question: "Ship it?", options: ["yes", "also yes"] },
});
await client.polls.vote({ poll_id: 1, option_id: 2 });Uploads
const file = new File(["hello"], "hello.txt", { type: "text/plain" });
const upload = await client.uploads.upload(file);
await client.thoughts.create({
content_raw: "uploaded a file",
attachment_ids: [upload.upload_id],
});Errors
try {
await client.thoughts.create({ content_raw: "hello" });
} catch (error) {
if (error instanceof AsterRateLimitError) {
console.log(error.retry_after_ms);
}
if (error instanceof AsterMissingScopeError) {
console.log(error.required_scope);
}
}All non-2xx responses throw AsterBotApiError or a more specific subclass.
Examples
You can visit the GitHub repository for richer examples.