pub struct Credentials {
pub api_key: String,
pub secret_key: String,
}Expand description
Authentication credentials for Alpaca API.
Fields§
§api_key: StringThe API key for authentication.
secret_key: StringThe secret key for authentication.
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn new(api_key: String, secret_key: String) -> Credentials
pub fn new(api_key: String, secret_key: String) -> Credentials
Create new credentials
Sourcepub fn from_env() -> Result<Credentials, AlpacaError>
pub fn from_env() -> Result<Credentials, AlpacaError>
Create credentials from environment variables.
This method automatically attempts to load a .env file if present.
Looks for ALPACA_API_KEY and either ALPACA_API_SECRET or ALPACA_SECRET_KEY.
Sourcepub fn auth_header(&self) -> String
pub fn auth_header(&self) -> String
Generate authorization header for HTTP requests
Sourcepub fn sign_request(
&self,
method: &str,
path: &str,
body: &str,
timestamp: DateTime<Utc>,
) -> Result<String, AlpacaError>
pub fn sign_request( &self, method: &str, path: &str, body: &str, timestamp: DateTime<Utc>, ) -> Result<String, AlpacaError>
Generate HMAC signature for request authentication
Sourcepub fn auth_headers(
&self,
method: &str,
path: &str,
body: &str,
) -> Result<HashMap<String, String>, AlpacaError>
pub fn auth_headers( &self, method: &str, path: &str, body: &str, ) -> Result<HashMap<String, String>, AlpacaError>
Generate headers for authenticated requests
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnwindSafe for Credentials
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more