Get started
Let's make your first post to Bluesky via the API in under 5 minutes.
Create a .NET project with the idunno.Bluesky nuget package
- At the command line run the following commands
dotnet new console -n HelloBluesky cd HelloBluesky dotnet add package idunno.Bluesky
Create a session
- Open the
Program.csfile in your editor of choice and change its contents to the following code, replacing the"handle"and"password"parameters in theagent.Login()call with your Bluesky handle and password.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
- Save the changed file.
- Open the
Program.csfile from the Solution Explorer window and change its contents to the following code, replacing the"handle"and"password"parameters for in theagent.Login()call with your Bluesky handle and password.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
- Save the changed file.
- Open the
Program.csfile from the Explorer window and change its contents to the following code, replacing the"handle"and"password"parameters for theagent.Login()method with your Bluesky handle and password.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
- Save the changed file. Open
Tip
Handles do not start with an @ sign, that's just how the official app and other apps choose to display them. When trying to login, or use other methods that take a handle make sure your strings do not begin with the @ sign.
Tip
You can create and use an App password instead of your login password.
App Passwords are safer as they allow sign in without granting full access to your Bluesky account.
Create a post
- Continue to change
Program.csby adding an additional line to create a post.using idunno.Bluesky; using BlueskyAgent agent = new(); await agent.Login(handle, password); await agent.Post("Hello World from idunno.Bluesky"); - Save the changed file and exit your editor.
- Compile and run your project with the following command
dotnet run
- Continue to change
Program.csby adding an additional line to create a post.using idunno.Bluesky; using BlueskyAgent agent = new(); await agent.Login(handle, password); await agent.Post("Hello World from idunno.Bluesky"); - Save the changed file.
- Run the project by pressing F5 or choosing Start Debugging under the Debug menu.
- Continue to change
Program.csby adding an additional line to create a post.using idunno.Bluesky; using BlueskyAgent agent = new(); await agent.Login(handle, password); await agent.Post("Hello World from idunno.Bluesky"); - Save the changed file.
- Run the project by pressing F5 or choosing Start Debugging under the Run menu.
The program should run without any errors, and if you check your own profile (click the Profile link in the app, or on bsky.app) you should see a post that says "Hello World from idunno.Bluesky".
Congratulations, you've just posted from code!
You can @ someone in the post text, add hashtags, or http/https links and they will all get turned into the right type of link. Try it and check in the app.
