TD Ameritrade is a stockbroker that offers an electronic trading platform for the trade of financial assets including common stocks, preferred stocks, futures contracts, exchange-traded funds, forex, options, mutual funds, fixed income investments, margin lending, and cash management services.
Go to siteimport { axios } from "@pipedream/platform"
export default defineComponent({
props: {
td_ameritrade: {
type: "app",
app: "td_ameritrade",
}
},
async run({steps, $}) {
return await axios($, {
url: `https://api.tdameritrade.com/v1/userprincipals`,
headers: {
Authorization: `Bearer ${this.td_ameritrade.$auth.oauth_access_token}`,
},
})
},
})
TD Ameritrade uses OAuth authentication. When you connect your TD Ameritrade account, Pipedream will open a popup window where you can sign into TD Ameritrade and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any TD Ameritrade API.
Pipedream requests the following authorization scopes when you connect your account:
AccountAccess
GET
https://auth.tdameritrade.com/auth
?
client_id={{oauth.client_id}}@AMER.OAUTHAP
&
redirect_uri={{oauth.redirect_uri}}
&
response_type=code
&
state={{oauth.state}}
&
scope={{oauth.space_separated_scopes}}
POST
https://api.tdameritrade.com/v1/oauth2/token
content-type: application/x-www-form-urlencoded
accept: application/json
client_id={{oauth.client_id}}
&
redirect_uri={{oauth.redirect_uri}}
&
grant_type=authorization_code
&
code={{oauth.code}}
&
access_type=offline
POST
https://api.tdameritrade.com/v1/oauth2/token
content-type: application/x-www-form-urlencoded
accept: application/json
client_id={{oauth.client_id}}
&
grant_type=refresh_token
&
refresh_token={{oauth.refresh_token}}