Welcome to the BlueSky package!
Links:
Getting Started
API:
const { API } = require("@elara-services/bluesky");
const api = new API({
keys: [
{ username: "catoftheday.bsky.social", appKey: "THE_APP_KEY_FROM_SETTINGS", service: "OPTIONAL_SERVICE_URL" },
],
debug: true,
defaultService: "https://bsky.social",
});
BskyAgents:
By default the package will use a random BskyAgent account data for the requests, to manage the agents on the fly:
BskyAgent: Add
api.agents.add([
]);
BskyAgent: Remove
api.agents.remove("username", "service");
BskyAgent: List
const list = api.agents.list();
BskyAgent: Search
const data = api.agents.search({
username: "xxx",
service: "https://bsky.social",
});
const data = api.agents.search({
username: "xxx",
service: "https://bsky.social",
}, "filter");
API: Fetch User(s):
const data = await api.users.fetch("catoftheday.bsky.social");
const data = await api.users.fetchMultiple(["catoftheday.bsky.social", "superchiefyt.xyz"]);
API: Fetch Feed(s):
const data = await api.users.feeds.fetch("catoftheday.bsky.social");
const data = await api.users.feeds.fetchMultiple([
"catoftheday.bsky.social",
"superchiefyt.xyz",
]);
API: Fetch User Likes:
const data = await api.users.likes.get("catoftheday.bsky.social");
Stream:
const { Stream } = require("@elara-services/bluesky");
const stream = new Stream({
keys: [
{ username: "catoftheday.bsky.social", appKey: "THE_APP_KEY_FROM_SETTINGS", service: "OPTIONAL_SERVICE_URL" },
],
searchMinutes: 2,
debug: true,
defaultService: "https://bsky.social",
}, "DISCORD_BOT_TOKEN");
await stream.start();
Stream: Add Users
stream.manage.add({
handle: "catoftheday.bsky.social",
channels: [
{
searchId: "",
channelId: "12345678",
url: "https://discord.com/api/webhooks/1234567/ASDASDFWHSDF",
roles: [],
color: "#fffff",
showButtons: true,
toggles: {
reposts: true,
},
options: {
username: "BlueSky",
avatar: "https://....",
content: "",
embeds: [
{
title: "New Post!",
description: "Go view it!"
}
],
components: [],
}
}
]
});
Stream: Remove user
stream.manage.remove(`catoftheday.bsky.social`);
stream.manage.remove(["catoftheday.bsky.social", "thedevil.bsky.social"]);
Stream: Get User
const data = stream.manage.get("catoftheday.bsky.social");
Stream: Clear Users
stream.manage.clear();
Stream: List Users
const list = stream.manage.list();
Stream: Edit User
const data = stream.manage.set("catoftheday.bsky.social", "channels.unique.searchId", {
});
Stream: Parser Options:
Package object:
const { p } = require("@elara-services/bluesky");
p.text;
Strings:
%text% - Will return the text for the post.
%created_at% - Will return the ISO Date for the post.
%type% - The type of post "post" or "repost"
%replies% - The number of replies
%likes% - The number of likes
%reposts% - The number of reposts
%links.url% - The post link
%links.uri% - The BlueSky URI
%links.cid% - The BlueSky CID for the post.
User info:
%user.name% - The user's display name (Example: Daily Cats)
%user.handle% - The user's handle (Example: catoftheday.bsky.social)
%user.id% - The user's ID
%user.avatar% - The user's avatar url
Repost info: (Note: All of the fields will return an empty string if it's not a repost)
%repost.user.name% - The username for the reposted user.
%repost.user.handle% - The handle for the reposted user.
%repost.user.id% - The ID for the reposted user.
%repost.user.avatar% - The avatar for the reposted user.
%repost.created_at% - The ISO Date for the post.