> [!NOTE] > This code is mostly useable. A few things are missing, like `.post()` and some other minor methods, but the majority is complete. # atproto_api [![Crates.io](https://img.shields.io/crates/v/atproto_api)](https://crates.io/crates/atproto_api) A simple [ATProto](https://atproto.com) implementation in Rust ## `AtpAgent` `AtpAgent` is meant for general AT Protocol operations. ### Initialization It can be initialized like this: ```rs #[macro_use] extern crate dotenv_codegen; use serde_json::json use atproto_api::{Agent, AtpAgent}; #[tokio::main] async fn main() -> Result<(), Box> { let agent = AtpAgent::new("https://fjall.net".to_string()); println!("{:?}", agent); Ok(()) } // AtpAgent { service: "https://fjall.net/", session: None } ``` ### Get request You can perform a get request by doing the following: ```rs // macros use dotenv_codegen::dotenv; use serde_json::json; use atproto_api::{Agent, AtpAgent}; #[tokio::main] async fn main() -> Result<(), Box> { let agent = AtpAgent::new("https://bsky.social".to_string()); let agent = agent .login( dotenv!("BLUESKY_IDENTIFIER").to_string(), dotenv!("BLUESKY_PASSWORD").to_string(), ) .await?; let record = json!({ "repo": "fjall.net", "collection": "app.bsky.feed.post", "rkey": "3k653jvvxlw2v" }); let res = agent .get("com.atproto.repo.getRecord".to_string(), record) .await?; println!("{:?}", res); Ok(()) } ``` The first parameter is a [lexicon](https://atproto.com/guides/lexicon), the specific ones you can view by scrolling down to the bottom of the page and looking through the "Lexicons" section. The second parameter is a record, which is a JSON object that contains the other important information (in the case of `com.atproto.repo.getRecord`, that's `repo`, `collection`, and `rkey`). ## `BskyAgent` > [!NOTE] > `BskyAgent` is currently on the backburner, as it's a superset of `AtpAgent`. If for some reason you're using this library *now*, please use `AtpAgent` instead of `BskyAgent` for the time being. ## License This code is licensed under the BSD 3-Clause license. You can view the license [here](https://git.sr.ht/~jordanreger/atproto_api/tree/main/item/LICENSE).