Start can not be after end

Hello! I am using Python to try to get the market data for yesterday, however it keeps returning an error. My code is

DATA_URL = "{}/bars".format(symbol)

starttime = pd.Timestamp('2021-09-14 09:30', tz=pytz.timezone('America/New_York'))
endtime = pd.Timestamp('2021-09-14 10:30', tz=pytz.timezone('America/New_York'))

data = {
    "timeframe": "1Min"


r = requests.get(DATA_URL, json=data, headers=HEADERS)
return_content = json.loads(r.content)

where HEADERS is simply my api key and secret key, and work on other parts of my application. Whenever I run this, it prints

{‘code’: 42210000, ‘message’: ‘start can not be after end’}

When I swap the start and end, it gives me the exact same error. Any advice on how to solve this?

Hi @nateroskelley,

The problem is in this line:

requests.get(DATA_URL, json=data, headers=HEADERS)

You are sending the parameters as an HTTP body, instead of query parameters.

The fix is:

requests.get(DATA_URL, params=data, headers=HEADERS)

Let us know if you have any other questions.