Easily call Neynar APIs with our Rust SDK
cargo new get-started-with-neynar-sdk cd get-started-with-neynar-sdk
cargo add --git https://github.com/neynarxyz/rust-sdk api
src/main.rs
use neynar_sdk::apis::configuration as api_config; use neynar_sdk::apis::configuration::Configuration as ApiConfig; use neynar_sdk::apis::user_api::{ FetchBulkUsersByEthOrSolAddressParams, fetch_bulk_users_by_eth_or_sol_address, }; use neynar_sdk::models::BulkUserAddressType::VerifiedAddress; use reqwest::Client; #[tokio::main] async fn main() -> { let configuration = ApiConfig { base_path: "https://api.neynar.com/v2".to_string(), client: Client::builder().connection_verbose(true).build().unwrap(), user_agent: Some("rust-sdk-demo".to_string()), api_key: Some(api_config::ApiKey { prefix: None, key: "NEYNAR_API_DOCS".to_string(), }), basic_auth: None, bearer_access_token: None, oauth_access_token: None, }; let addresses = "0xBFc7CAE0Fad9B346270Ae8fde24827D2D779eF07".to_string(); let params = FetchBulkUsersByEthOrSolAddressParams { addresses, address_types: Some(vec![VerifiedAddress]), viewer_fid: None, x_neynar_experimental: None, }; let result = fetch_bulk_users_by_eth_or_sol_address(&configuration, params).await; match result { Ok(response) => { println!("Users: {:?}", response.additional_properties); } Err(err) => { eprintln!("Failed to fetch users: {:?}", err); panic!("User fetch failed"); } } }
cargo run
Users [{ fid: 20603, username: "topocount.eth", display_name: "Topocount", // ...other fields... }]
Was this page helpful?