Skip to main content

Get Started

Make your first post to the Bluesky app via the API in under 5 minutes.

Install the SDK

Choose the SDK you want to work with. Below, we use TypeScript and Python. You can follow the instructions for the community-maintained atproto.dart package here.

Install @atproto/api using your preferred package manager.

yarn add @atproto/api

Create a session

Create an authentication session with your username and password.

import { BskyAgent } from '@atproto/api'

const agent = new BskyAgent({
service: 'https://bsky.social'
})
await agent.login({
identifier: 'handle.example.com',
password: 'hunter2'
})

The com.atproto.server.createSession API endpoint returns a session object containing two API tokens:

  • accessJwt: an access token which is used to authenticate requests but expires after a few minutes
  • refreshJwt: a refresh token which lasts longer and is used only to update the session with a new access token

The agent object stores this session information for you, and will include it in the headers of its requests.

Create a post

Now you can create a post by sending a POST request to the createRecord endpoint.

await agent.post({
text: 'Hello world! I posted this via the API.',
createdAt: new Date().toISOString()
})

This will return an object containing the post's URI and a CID (a hash of the content).

{
"uri": "at://did:plc:abc123..../app.bsky.feed.post/xyz...",
"cid": "abc..."
}

Check out your profile to see the post you just created!

Next Steps