// let's count the number of likes on a Bluesky post // ...but without using any Bluesky infrastructure at all! // Constellation knows about *all* references to every record // This API counts up the unique identities from those references const url = new URL('https://constellation.microcosm.blue/links/count/distinct-dids') // set the bluesky post's record at-uri as the "target" const record_uri = 'at://did:plc:hdhoaan3xa3jiuq4fg4mefid/app.bsky.feed.post/3lwcmto4tck2h'; url.searchParams.set('target', record_uri); // filter references to those from bluesky likes url.searchParams.set('collection', 'app.bsky.feed.like') url.searchParams.set('path', '.subject.uri') // let's go! const res = await fetch(url); const { total } = await res.json(); // total now has the count of likes on our post!