Just getting started, problem with api.get_account


Coding in Python3, Google Colab, Chrome browser

Hey all, as indicated in the title, I’m just getting started and a relative noob. I followed the Google Colab template with the following code:

import alpaca_trade_api as alpaca

api = alpaca.REST(‘API_KEY_ID’, ‘API_SECRET_KEY’, ‘https://api.alpaca.markets/’)


BUT, when I run the code, I get the following error message:

HTTPError Traceback (most recent call last)
in ()
----> 1 api.get_account()

4 frames
/usr/local/lib/python3.6/dist-packages/requests/models.py in raise_for_status(self)
939 if http_error_msg:
–> 940 raise HTTPError(http_error_msg, response=self)
942 def close(self):

HTTPError: 404 Client Error: Not Found for url: https://api.alpaca.markets//v2/account

I double-checked the keys and the URL, and I didn’t get an error message before running the api.get_account() command.

Multiple things about this confuse me, but at the top of the list is the URL… /v2/account? I read the documentation, and shouldn’t the endpoint be /v1/account? I don’t see a way to change the endpoint either.

I should also mention that I’ve put in a transfer request to fund my account, but the money isn’t actually in the account yet, so I’m not sure if that’s what’s causing this error message. I assumed the command would still work and I’d just get back output saying something to the effect of no money, no open orders, no positions, etc.

Thanks in advance!

Nice, thank you for trying Alpaca+Colab!
Can you try without the trailing slash for the endpoint parameter?

api = alpaca.REST(‘API_KEY_ID’, ‘API_SECRET_KEY’, ‘https://api.alpaca.markets’)

The current API version is v2 and it is not recommended to use v1. The error doesn’t have to do with your money transfer status.

Thanks Hitoshi,

I deleted the trailing hash, and it’s working now. I’m reading the documentation for v2 now to avoid similar confusion in the future.