A decentralized music tracking and discovery platform built on AT Protocol 馃幍
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
1import { ROCKSKY_API_URL } from "../consts";
2import type { Scrobble } from "../types/scrobble";
3
4export default async function getRecentScrobbles(handle: string) {
5 const url = new URL(
6 `${ROCKSKY_API_URL}/xrpc/app.rocksky.actor.getActorScrobbles`,
7 );
8 url.searchParams.append("did", handle);
9 url.searchParams.append("limit", "20");
10 const res = await fetch(url);
11
12 if (!res.ok) {
13 return { scrobbles: [], ok: res.ok };
14 }
15
16 const { scrobbles } = (await res.json()) as { scrobbles: Scrobble[] };
17 return { scrobbles, ok: res.ok };
18}