TD Ameritrade API Get Positions

I'm testing out the TD Ameritrade API. I'm attempting to retrieve a given user's positions (open and closed).

I'm successfully authenticating and retrieving my accountId from a front-end+server I've set up.

I use my accountId and make a GET request to this url: https://api.tdameritrade.com/v1/accounts/{acountId} as described in the docs here: https://developer.tdameritrade.com/account-access/apis/get/accounts/%7BaccountId%7D-0

This GET request is successful however there is no positions object returned by the response within the parent data object as outlined in the API docs.

Does anyone know if the positions object only applies to closed positions, or does it include open ones as well? Any clarity appreciated. I have one open position, and none closed.

I'm not including code as the GET requests work, this is a question of why the TD Ameritrade API data coming back does not contain an object that the documentation says it should.


Solution 1:

This was a simple fix - despite the docs not mentioning this, if you want to get the positions of a given account, you have to explicitly append the parameters ?fields=positions to the endpoint:

https://api.tdameritrade.com/v1/accounts/${accountId}?fields=positions