Retro Bulletin Board Systems on atproto. Web app and TUI.
lazy mirror of alyraffauf/atbbs
atbbs.xyz
forums
python
tui
atproto
bbs
1/** Bluesky public API helpers. */
2
3const BSKY_PUBLIC = "https://public.api.bsky.app";
4
5export interface HandleMatch {
6 handle: string;
7 displayName: string;
8 avatar?: string;
9}
10
11export async function searchHandles(
12 query: string,
13 limit = 5,
14): Promise<HandleMatch[]> {
15 const url =
16 `${BSKY_PUBLIC}/xrpc/app.bsky.actor.searchActorsTypeahead` +
17 `?q=${encodeURIComponent(query)}&limit=${limit}`;
18 const resp = await fetch(url);
19 if (!resp.ok) return [];
20 const data = (await resp.json()) as {
21 actors: {
22 handle: string;
23 displayName?: string;
24 avatar?: string;
25 }[];
26 };
27 return data.actors.map((actor) => ({
28 handle: actor.handle,
29 displayName: actor.displayName ?? actor.handle,
30 avatar: actor.avatar,
31 }));
32}