interacting with bluesky
Code snippets to help you access the Bluesky API through Apps Script
Bluesky
Bluesky is a Twitter/X clone that is attracting an increasing migration of teachers from X. While the Bluesky app allows for a straightforward interaction, users can also use the Bluesky API to programmatically automate tasks, such as searching profile descriptions for keywords and adding the resulting users to a list.
The Bluesky API can be accessed in multiple ways, but doing so through Apps Script requires zero set-up or software, making it the quickest and simplest way to make a start.
This is also a good vehicle to illustrate how to use the Google Apps Script UrlFetchApp class, which is used to make API requests to applications/resources on the web. API requests to Google are handled by the built-in Google services (and optional advanced services), but UrlFetchApp handles requests to other websites.
-
Authenticate a session to get a bearer token

Create an authenticated session and obtain a bearer token for use with the Bluesky API when creating or modifying records.
-
List a user’s followers and follows

List a Bluesky user’s followers and follows programmatically so that they can be compared to identify mismatches.
-
Resolve a handle into a DID

Bluesky handles can be changed but the underlying DID is persistent. Learn how to lookup the DID from a handle, for use in API calls.
Share this via: