Skip to content

Commit f94fcf4

Browse files
authored
doc: Add example of how to create a Post on bsky (#255)
Adds an example to the README in the `bsky-sdk`. This is often the first thing new users will want to try when interacting with the SDK.
1 parent c892ece commit f94fcf4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Diff for: bsky-sdk/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,36 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
108108
}
109109
```
110110

111+
### Posts
112+
113+
Create a BlueSky post:
114+
115+
```rust,no_run
116+
use atrium_api::types::string::Datetime;
117+
use bsky_sdk::BskyAgent;
118+
119+
#[tokio::main]
120+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
121+
let agent = BskyAgent::builder().build().await?;
122+
agent.login("...", "...").await?;
123+
124+
agent
125+
.create_record(atrium_api::app::bsky::feed::post::RecordData {
126+
created_at: Datetime::now(),
127+
embed: None,
128+
entities: None,
129+
facets: None,
130+
labels: None,
131+
langs: None,
132+
reply: None,
133+
tags: None,
134+
text: "Hello world, from Rust!".to_string(),
135+
})
136+
.await?;
137+
Ok(())
138+
}
139+
```
140+
111141
### RichText
112142

113143
Creating a RichText object from a string:

0 commit comments

Comments
 (0)