IB API vs TD Ameritrade API

What o/s u using? I had same issue for weeks. After going back/forth w email support, they send me a link about windows 8 or below having issues. Iam like"why did u not tell me this weeks ago! After buying win 10 laptop... worked like a charm. quick shoutout of thanks to spyalgo for helping me as well!! :-)
 
What o/s u using? I had same issue for weeks. After going back/forth w email support, they send me a link about windows 8 or below having issues. Iam like"why did u not tell me this weeks ago! After buying win 10 laptop... worked like a charm. quick shoutout of thanks to spyalgo for helping me as well!! :)
I guess this was question for me. I am using windows 10. Received authorization code. Inserted it on their website to obtain the token but keep getting 'invalid_grant' error. It should be straightforward process. What redirect_uri are you using?
 
I have to look at my notes. I encountered all the errors you are in now, swapped to win 10, got it working BUT I returned my new laptop for a faster 1 which should be arriving any day. I am slammed with finals for my MS so once I stop drowning in school work, will focus on TDAPI which I need to do in next days or so. BTW, TD emails to API suppport (Michael) is pretty quick which was the only pleasant thing in this episode.
 
I have to look at my notes. I encountered all the errors you are in now, swapped to win 10, got it working BUT I returned my new laptop for a faster 1 which should be arriving any day. I am slammed with finals for my MS so once I stop drowning in school work, will focus on TDAPI which I need to do in next days or so. BTW, TD emails to API suppport (Michael) is pretty quick which was the only pleasant thing in this episode.
Ok, thank you, maybe you will have any tips for me.
 
Ok, thank you, maybe you will have any tips for me.
See if this python code helps. The XXXX is assigned when you get your TD API ID (unique to you I think), obviously myloginname and mypassword is specific to you as well.

The login function returns the login response as well as the session object. That session object has to be passed into the subsequent call to ensure it's already authenticated. This is as straightforward as a http post goes, you can literally put it into a curl and it'll still work.

<The indents are off but otherwise the code is runnable, you'll need to import the python requests api>


def getQuotes(mysymbol,s):
returnval=s.get("https://apis.tdameritrade.com/apps/100/Quote?source=XXXX&symbol="+mysymbol)
returntext = returnval.text
returntext2close=returntext[returntext.index('<last>')+6:returntext.index('</last>')]
returntext2open=returntext[returntext.index('<open>')+6:returntext.index('</open>')]
returntext2volume=returntext[returntext.index('<volume>')+8:returntext.index('</volume>')]
returntext2high=returntext[returntext.index('<high>')+6:returntext.index('</high>')]
returntext2low=returntext[returntext.index('<low>')+5:returntext.index('</low>')]
#print returntext2
# print returntext
return returntext2close,returntext2open,returntext2high,returntext2low,returntext2volume


def login():
payload = {'source':'XXXX','userid':'myloginname','password':'mypassword','version':'100'}
s=requests.session()
r = s.post("https://apis.tdameritrade.com/apps/100/LogIn?source=XXXX&version=100",data=payload)
output = r.text
return s,output
 
Last edited:
See if this python code helps. The XXXX is assigned when you get your TD API ID (unique to you I think), obviously myloginname and mypassword is specific to you as well.

The login function returns the login response as well as the session object. That session object has to be passed into the subsequent call to ensure it's already authenticated. This is as straightforward as a http post goes, you can literally put it into a curl and it'll still work.


def getQuotes(mysymbol,s):
returnval=s.get("https://apis.tdameritrade.com/apps/100/Quote?source=XXXX&symbol="+mysymbol)
returntext = returnval.text
returntext2close=returntext[returntext.index('<last>')+6:returntext.index('</last>')]
returntext2open=returntext[returntext.index('<open>')+6:returntext.index('</open>')]
returntext2volume=returntext[returntext.index('<volume>')+8:returntext.index('</volume>')]
returntext2high=returntext[returntext.index('<high>')+6:returntext.index('</high>')]
returntext2low=returntext[returntext.index('<low>')+5:returntext.index('</low>')]
#print returntext2
# print returntext
return returntext2close,returntext2open,returntext2high,returntext2low,returntext2volume
def login():
payload = {'source':'XXXX','userid':'myloginname','password':'mypassword','version':'100'}
s=requests.session()
r = s.post("https://apis.tdameritrade.com/apps/100/LogIn?source=XXXX&version=100",data=payload)
output = r.text
return s,output
Geting quotes works for me. It does not require oauth token. This is getting oauth token I am having trouble with. Thanks for the post.
 
Back
Top