First time to algorithm trading, python, and Quantitate Finance so apologies up front. I have noticed a lack of any good documentation for the TD Ameritrade API anywhere and especially with any of the less common API calls. I am having trouble with the "Get Orders By Query" API call and am looking for either a place that has example code/documentation or perhaps make this post the go to for future people trying to get this call working. The following is my current code with the variable account_id being my 9 digit TD account number and the headers variable being {'Authorization': 'Bearer PhE7Be0aFAKsp2DSfXtCciiz...} .
def Standing_Orders(headers, account_id):
endpoint = 'https://api.tdameritrade.com/v1/orders'
payload = {
'accountId': account_id,
'fromEnteredTime': '2020-08-03',
'toEnteredTime': '2020-08-03',
'status': 'QUEUED'
}
content = requests.post(url=endpoint, json=payload, headers=headers)
return content
The code keeps returning the error <Response [400]>. I am only using the requests library for the code above. My authorization is working because I am able to place buy/sell orders with my header variable. I have also had success pulling my queued orders from https://developer.tdameritrade.com/account-access/apis/get/orders-0 using the same variables and payload showed above. I am a bit lost. Thanks in advance!