Rust
Rust
ETrade v1 List Transactions
See more HTTP Misc Examples
Get information about the transactions in an ETrade brokerage account.Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
http.set_o_auth1(true);
http.set_o_auth_verifier("");
http.set_o_auth_consumer_key("ETRADE_CONSUMER_KEY");
http.set_o_auth_consumer_secret("ETRADE_CONSUMER_SECRET");
// Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2.
let json = chilkat::JsonObject::new();
if json.load_file("qa_data/tokens/etrade.json").is_err() {
println!("Failed to load OAuth1 token");
return;
}
http.set_o_auth_token(&json.string_of("oauth_token").unwrap_or_default());
http.set_o_auth_token_secret(&json.string_of("oauth_token_secret").unwrap_or_default());
// See the ETrade v1 API documentation HERE.
let _ = http.set_url_var("accountIdKey", "vsnhtF7d9jXxBy6HyaAC4vQ");
let Ok(resp_str) = http.quick_get_str("https://apisb.etrade.com/v1/accounts/{$accountIdKey}/transactions") else {
println!("{}", http.last_error_text());
return;
};
// A 200 status code indicates success.
let status_code = http.last_status();
println!("statusCode = {}", status_code);
// Use the following online tool to generate parsing code from sample XML:
// Generate Parsing Code from XML
// A sample XML response is shown below...
let xml = chilkat::Xml::new();
let _ = xml.load_xml(&resp_str);
let mut i: i32 = 0;
i = 0;
let count_i = xml.num_children_having_tag("Transaction");
while i < count_i {
xml.set_i(i);
let _ = xml.get_child_content("Transaction[i]|transactionId").unwrap_or_default();
let _ = xml.get_child_int_value("Transaction[i]|accountId");
let _ = xml.get_child_content("Transaction[i]|transactionDate").unwrap_or_default();
let _ = xml.get_child_content("Transaction[i]|postDate").unwrap_or_default();
let _ = xml.get_child_int_value("Transaction[i]|amount");
let _ = xml.get_child_content("Transaction[i]|description").unwrap_or_default();
let _ = xml.get_child_int_value("Transaction[i]|description2");
let _ = xml.get_child_content("Transaction[i]|transactionType").unwrap_or_default();
let _ = xml.get_child_content("Transaction[i]|imageFlag").unwrap_or_default();
let _ = xml.get_child_content("Transaction[i]|instType").unwrap_or_default();
let _ = xml.get_child_int_value("Transaction[i]|brokerage|quantity");
let _ = xml.get_child_int_value("Transaction[i]|brokerage|price");
let _ = xml.get_child_content("Transaction[i]|brokerage|settlementCurrency").unwrap_or_default();
let _ = xml.get_child_content("Transaction[i]|brokerage|paymentCurrency").unwrap_or_default();
let _ = xml.get_child_int_value("Transaction[i]|brokerage|fee");
let _ = xml.get_child_content("Transaction[i]|brokerage|settlementDate").unwrap_or_default();
let _ = xml.get_child_content("Transaction[i]|detailsURI").unwrap_or_default();
i = i + 1;
}
let page_markers = xml.get_child_content("pageMarkers").unwrap_or_default();
let more_transactions = xml.get_child_content("moreTransactions").unwrap_or_default();
let transaction_count = xml.get_child_int_value("transactionCount");
let total_count = xml.get_child_int_value("totalCount");
// <?xml version="1.0" encoding="UTF-8"?>
// <TransactionListResponse>
// <Transaction>
// <transactionId>18165100001766</transactionId>
// <accountId>83564979</accountId>
// <transactionDate>1528948800000</transactionDate>
// <postDate>1528948800000</postDate>
// <amount>-2</amount>
// <description>ACH WITHDRAWL REFID:109187276;</description>
// <description2>109187276</description2>
// <transactionType>Transfer</transactionType>
// <memo />
// <imageFlag>false</imageFlag>
// <instType>BROKERAGE</instType>
// <brokerage>
// <product />
// <quantity>0</quantity>
// <price>0</price>
// <settlementCurrency>USD</settlementCurrency>
// <paymentCurrency>USD</paymentCurrency>
// <fee>0</fee>
// <settlementDate>1528948800000</settlementDate>
// </brokerage>
// <detailsURI>https://api.etrade.com/v1/accounts/yIFaUoJ81qyAhgxLWRQ42g/transactions/18165100001766</detailsURI>
// </Transaction>
// <Transaction>
// <transactionId>18158100000983</transactionId>
// <accountId>83564979</accountId>
// <transactionDate>1528344000000</transactionDate>
// <postDate>1528344000000</postDate>
// <amount>-2</amount>
// <description>ACH WITHDRAWL REFID:98655276;</description>
// <description2>98655276</description2>
// <transactionType>Transfer</transactionType>
// <memo />
// <imageFlag>false</imageFlag>
// <instType>BROKERAGE</instType>
// <brokerage>
// <product />
// <quantity>0</quantity>
// <price>0</price>
// <settlementCurrency>USD</settlementCurrency>
// <paymentCurrency>USD</paymentCurrency>
// <fee>0</fee>
// <settlementDate>1528344000000</settlementDate>
// </brokerage>
// <detailsURI>https://api.etrade.com/v1/accounts/yIFaUoJ81qyAhgxLWRQ42g/transactions/18158100000983</detailsURI>
// </Transaction>
// <pageMarkers>eNpTsAlITE91zi%2FNK%2FHMc04syi8tTs2xM7TRxybMpWATkl%2BSmBOUmpxflAKWtTO10ccQg6mDmwEyEE0EqAbE8SvNTUotCk4tLE3NS061M9Ax0DEEYgOIA9BkuRQgmjxTfDKLQUYoQAV8E4uyU4vsDC0MzUwNDYDA0NzMrKamBmIKVJYLphpiKsyTUB7IbH1kwwFa7F0D</pageMarkers>
// <moreTransactions>false</moreTransactions>
// <transactionCount>5</transactionCount>
// <totalCount>5</totalCount>
// </TransactionListResponse>