1use jacquard::api::app_bsky::feed::get_feed::GetFeed;
2use jacquard::api::app_bsky::feed::post::Post;
3use jacquard::types::string::AtUri;
4use jacquard::types::value::from_data;
5use jacquard::xrpc::XrpcExt;
6use miette::IntoDiagnostic;
7
8#[tokio::main]
9async fn main() -> miette::Result<()> {
10 // Stateless XRPC - no auth required for public feeds
11 let http = reqwest::Client::new();
12 let base = url::Url::parse("https://public.api.bsky.app").into_diagnostic()?;
13
14 // Feed of posts about the AT Protocol
15 let feed_uri =
16 AtUri::new_static("at://did:plc:oio4hkxaop4ao4wz2pp3f4cr/app.bsky.feed.generator/atproto")
17 .unwrap();
18
19 let request = GetFeed::new().feed(feed_uri).limit(10).build();
20
21 let response = http.xrpc(base).send(&request).await?;
22 let output = response.into_output()?;
23
24 println!("Latest posts from the AT Protocol feed:\n");
25 for (i, item) in output.feed.iter().enumerate() {
26 // Deserialize the post record from the Data type
27 let post: Post = from_data(&item.post.record).into_diagnostic()?;
28 println!("{}.(@{})\n{} ", i + 1, item.post.author.handle, post.text);
29 }
30
31 Ok(())
32}