SDKs overview

Bluesky's development ecosystem centers around the Authentic Transfer (AT) Protocol, a federated network protocol designed for large-scale distributed applications. SDKs and libraries for Bluesky are designed to simplify interaction with this protocol, allowing developers to build clients, bots, and services that integrate with the Bluesky network. The AT Protocol specifies decentralized identifiers (DIDs), data repositories (Repos), and a lexicon system for defining public APIs, which collectively form the foundation for Bluesky's decentralized social applications on the Bluesky protocol.

The primary official SDK is written in TypeScript, providing a robust interface for both client-side and server-side development. This SDK abstracts away the complexities of cryptographic signing, data serialization, and network communication inherent to the AT Protocol. Community contributions extend the reach of Bluesky development by offering libraries in other programming languages, enabling a broader range of applications and integrations beyond the official TypeScript tooling.

Developers utilizing Bluesky SDKs can perform actions such as creating posts, following users, managing user data, and interacting with custom feeds. The protocol design emphasizes user data ownership and interoperability, which is reflected in the capabilities exposed by the SDKs for application development.

Official SDKs by language

The official development kit for Bluesky is provided in TypeScript, offering comprehensive support for interacting with the AT Protocol. This SDK is maintained by the Bluesky team and serves as the authoritative interface for building applications that integrate with the Bluesky network.

The official TypeScript SDK provides modules for:

  • Client Interaction: Methods for authenticating users, fetching data from the Bluesky network, and performing actions like posting, liking, and following.
  • Repository Management: Tools for managing user data stored in their personal data repositories (Repos), including CRUD operations on records defined by Lexicons within the AT Protocol.
  • Protocol Primitives: Lower-level access to AT Protocol components such as DIDs, Lexicons, and cryptographic utilities, enabling advanced use cases.
  • Type Definitions: Comprehensive TypeScript type definitions for all API responses and request bodies, enhancing developer experience with strong typing and auto-completion.
Language Package/Repository Install Command Maturity
TypeScript/JavaScript @atproto/api npm install @atproto/api or yarn add @atproto/api Stable, Actively Maintained
TypeScript/JavaScript @atproto/identity npm install @atproto/identity or yarn add @atproto/identity Stable, Actively Maintained
TypeScript/JavaScript @atproto/repo npm install @atproto/repo or yarn add @atproto/repo Stable, Actively Maintained

Installation

To begin development with the official Bluesky TypeScript SDK, you must have Node.js and npm (or Yarn/pnpm) installed on your system. The primary package for interacting with the Bluesky API is @atproto/api. Other core packages like @atproto/identity and @atproto/repo provide lower-level utilities for managing DIDs and repositories, respectively.

Prerequisites

  • Node.js (LTS version recommended)
  • npm, Yarn, or pnpm package manager

Installation Steps

Open your terminal or command prompt and navigate to your project directory. Then, execute the appropriate installation command:

Using npm:

npm install @atproto/api
npm install @atproto/identity
npm install @atproto/repo

Using Yarn:

yarn add @atproto/api
yarn add @atproto/identity
yarn add @atproto/repo

Using pnpm:

pnpm add @atproto/api
pnpm add @atproto/identity
pnpm add @atproto/repo

After installation, you can import and use the modules in your TypeScript or JavaScript project. For instance, to interact with the Bluesky network, you would typically import the BskyAgent from @atproto/api as described in the client libraries guide.

Quickstart example

This example demonstrates how to use the @atproto/api SDK to log in to Bluesky and publish a text post. Ensure you have installed the @atproto/api package as described in the installation section.

import { BskyAgent } from '@atproto/api';

// Replace with your Bluesky handle and app password
const BLUESKY_HANDLE = 'your-handle.bsky.social';
const BLUESKY_APP_PASSWORD = 'your-app-password'; // Generate this in Bluesky settings

async function postToBluesky() {
  const agent = new BskyAgent({
    service: 'https://bsky.social',
  });

  try {
    // Log in to Bluesky
    await agent.login({
      identifier: BLUESKY_HANDLE,
      password: BLUESKY_APP_PASSWORD,
    });
    console.log(`Logged in as ${agent.session?.handle}`);

    // Publish a post
    const postResult = await agent.post({
      text: 'Hello from the Bluesky SDK quickstart example! #BlueskySDK #ATProtocol',
    });
    console.log('Post published successfully:', postResult.uri);

  } catch (error) {
    console.error('Error posting to Bluesky:', error);
  }
}

postToBluesky();

To run this example:

  1. Save the code as a .ts file (e.g., quickstart.ts).
  2. Ensure you have TypeScript installed (npm install -g typescript).
  3. Compile the TypeScript file: tsc quickstart.ts
  4. Run the compiled JavaScript file: node quickstart.js

Remember to replace 'your-handle.bsky.social' and 'your-app-password' with your actual Bluesky credentials. App passwords can be generated in your Bluesky account settings for security as recommended for programmatic access.

Community libraries

Beyond the official TypeScript SDK, the Bluesky developer community has contributed libraries and tools in various programming languages. These community-driven projects aim to provide alternative interfaces to the AT Protocol, catering to developers working in different environments or with specific language preferences. While not officially supported by Bluesky, these libraries often follow the AT Protocol specifications and can be valuable resources for development.

Examples of community contributions often include:

  • Python Libraries: For scripting, data analysis, and building bots.
  • Go Libraries: For high-performance backend services and network tools.
  • Rust Libraries: For systems programming and applications requiring memory safety and performance.
  • Dart/Flutter Libraries: For cross-platform mobile application development.
  • API Clients: Simplified HTTP clients that wrap the AT Protocol's RESTful endpoints.

Developers interested in community libraries should explore platforms like GitHub, searching for repositories tagged with Bluesky, ATProtocol, or bsky. It is advisable to review the documentation, activity, and community support for any third-party library before integrating it into production systems. For instance, the Python Package Index (PyPI) may list Bluesky-related packages, or developers might find discussions on forums like Stack Overflow about Bluesky development on Stack Overflow.

When using community libraries, developers should be aware that:

  • Maturity and Maintenance: Vary significantly across projects.
  • Feature Parity: May not cover all functionalities of the official SDK or the latest AT Protocol specifications immediately.
  • Security: It is crucial to vet third-party code, especially when handling user credentials or sensitive data.

The Bluesky documentation provides detailed specifications of the AT Protocol for custom client implementation, which community libraries typically adhere to.