Any help with this API error please (Trying to set up paper trading API)

import requests

API_KEY = “PKVPYB865NXXX25YZXXX”
SECRET_KEY = “BE76FFsBHgeZ46VXxxOHAInpuwW6V7VXHn1gTGsy”

BASE_URL = “https://paper-api.alpaca.markets
ACCOUNT_URL = “{}/V2/account”.format(BASE_URL)

r = requests.get(ACCOUNT_URL, headers={‘APCA-API-KEY-ID’: API_KEY, ‘APCA-API-SECRET-KEY’: SECRET_KEY})

print(r.content)

Error Message is:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “alpaca_client.py”, line 6, in
account = api.get_account()
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/alpaca_trade_api/rest.py”, line 171, in get_account
resp = self.get(’/account’)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/alpaca_trade_api/rest.py”, line 152, in get
return self._request(‘GET’, path, data)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/alpaca_trade_api/rest.py”, line 115, in _request
return self._one_request(method, url, opts, retry)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/alpaca_trade_api/rest.py”, line 144, in _one_request
raise APIError(error, http_error)
alpaca_trade_api.rest.APIError: account not found for 67527d0e-0357-4c10-b3fa-b1c2d6f825e7

try this,
api = tradeapi.REST(API_KEY, SECRET_KEY, BASE_URL, api_version=‘v2’)
account = api.get_account()
print(account)

to post order
api.submit_order(‘AAPL’, 10, ‘buy’, ‘market’, ‘day’)

1 Like

thanks!, already solved by using os to bring the site to environment and worked out…

2 Likes

How did you solve it…
I am getting the same error

1 Like