DataFlex
DataFlex
ETrade v1 List Transactions
See more HTTP Misc Examples
Get information about the transactions in an ETrade brokerage account.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Handle hoJson
String sRespStr
Integer iStatusCode
Handle hoXml
Integer i
Integer iCount_i
String sTagPath
String sTransactionId
Integer iAccountId
String sTransactionDate
String sPostDate
Integer iAmount
String sDescription
Integer iDescription2
String sTransactionType
String sImageFlag
String sInstType
Integer iQuantity
Integer iPrice
String sSettlementCurrency
String sPaymentCurrency
Integer iFee
String sSettlementDate
String sDetailsURI
String sPageMarkers
String sMoreTransactions
Integer iTransactionCount
Integer iTotalCount
String sTemp1
Boolean bTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Set ComOAuth1 Of hoHttp To True
Set ComOAuthVerifier Of hoHttp To ""
Set ComOAuthConsumerKey Of hoHttp To "ETRADE_CONSUMER_KEY"
Set ComOAuthConsumerSecret Of hoHttp To "ETRADE_CONSUMER_SECRET"
// Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2.
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComLoadFile Of hoJson "qa_data/tokens/etrade.json" To iSuccess
If (iSuccess <> True) Begin
Showln "Failed to load OAuth1 token"
Procedure_Return
End
Get ComStringOf Of hoJson "oauth_token" To sTemp1
Set ComOAuthToken Of hoHttp To sTemp1
Get ComStringOf Of hoJson "oauth_token_secret" To sTemp1
Set ComOAuthTokenSecret Of hoHttp To sTemp1
// See the ETrade v1 API documentation HERE.
Get ComSetUrlVar Of hoHttp "accountIdKey" "vsnhtF7d9jXxBy6HyaAC4vQ" To iSuccess
Get ComQuickGetStr Of hoHttp "https://apisb.etrade.com/v1/accounts/{$accountIdKey}/transactions" To sRespStr
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 <> True) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
// A 200 status code indicates success.
Get ComLastStatus Of hoHttp To iStatusCode
Showln "statusCode = " iStatusCode
// Use the following online tool to generate parsing code from sample XML:
// Generate Parsing Code from XML
// A sample XML response is shown below...
Get Create (RefClass(cComChilkatXml)) To hoXml
If (Not(IsComObjectCreated(hoXml))) Begin
Send CreateComObject of hoXml
End
Get ComLoadXml Of hoXml sRespStr To iSuccess
Move 0 To i
Get ComNumChildrenHavingTag Of hoXml "Transaction" To iCount_i
While (i < iCount_i)
Set ComI Of hoXml To i
Get ComGetChildContent Of hoXml "Transaction[i]|transactionId" To sTransactionId
Get ComGetChildIntValue Of hoXml "Transaction[i]|accountId" To iAccountId
Get ComGetChildContent Of hoXml "Transaction[i]|transactionDate" To sTransactionDate
Get ComGetChildContent Of hoXml "Transaction[i]|postDate" To sPostDate
Get ComGetChildIntValue Of hoXml "Transaction[i]|amount" To iAmount
Get ComGetChildContent Of hoXml "Transaction[i]|description" To sDescription
Get ComGetChildIntValue Of hoXml "Transaction[i]|description2" To iDescription2
Get ComGetChildContent Of hoXml "Transaction[i]|transactionType" To sTransactionType
Get ComGetChildContent Of hoXml "Transaction[i]|imageFlag" To sImageFlag
Get ComGetChildContent Of hoXml "Transaction[i]|instType" To sInstType
Get ComGetChildIntValue Of hoXml "Transaction[i]|brokerage|quantity" To iQuantity
Get ComGetChildIntValue Of hoXml "Transaction[i]|brokerage|price" To iPrice
Get ComGetChildContent Of hoXml "Transaction[i]|brokerage|settlementCurrency" To sSettlementCurrency
Get ComGetChildContent Of hoXml "Transaction[i]|brokerage|paymentCurrency" To sPaymentCurrency
Get ComGetChildIntValue Of hoXml "Transaction[i]|brokerage|fee" To iFee
Get ComGetChildContent Of hoXml "Transaction[i]|brokerage|settlementDate" To sSettlementDate
Get ComGetChildContent Of hoXml "Transaction[i]|detailsURI" To sDetailsURI
Move (i + 1) To i
Loop
Get ComGetChildContent Of hoXml "pageMarkers" To sPageMarkers
Get ComGetChildContent Of hoXml "moreTransactions" To sMoreTransactions
Get ComGetChildIntValue Of hoXml "transactionCount" To iTransactionCount
Get ComGetChildIntValue Of hoXml "totalCount" To iTotalCount
// <?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
End_Procedure