A better Rust ATProto crate
103
fork

Configure Feed

Select the types of activity you want to include in your feed.

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