[ Paper trading ] 404 Client Error: Not Found

While trying to buy through paper trade api.

BASE_URL = 'https://paper-api.alpaca.markets'  
api = tradeapi.REST(key_id=PUB_KEY, secret_key=SEC_KEY, base_url=BASE_URL)
Traceback (most recent call last):
  File "/Users/kk/Github/alpaca_trade/alpaca_paper_trade.py", line 21, in <module>
    market_data = api.get_barset(symb, 'minute', limit=5)  # Get one bar object for each of the past 5 minutes
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/deprecation.py", line 260, in _inner
    return function(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 578, in get_barset
    resp = self.data_get('/bars/{}'.format(timeframe), params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 255, in data_get
    return self._request(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 202, in _request
    return self._one_request(method, url, opts, retry)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/alpaca_trade_api/rest.py", line 223, in _one_request
    resp.raise_for_status()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://data.alpaca.markets/v1/bars/minute?symbols=TSLA&limit=5

https://data.alpaca.markets/ is saying "403 forbidden "

Have you installed all the required packages before running this code? Install and try alpaca_trade_api instead, and try running your code again.

@kkraju90 Your Python code uses the get_barset function based on the Alpaca Data API v1 endpoint. This endpoint now is deprecated and you should upgrade your code and start using the get_bars function based on the v2 endpoint.

how to install the v2 of the api