# Alpaca Data API is not observing start/end query parameters

**URL:** https://forum.alpaca.markets/t/alpaca-data-api-is-not-observing-start-end-query-parameters/3767
**Category:** Alpaca Market Data
**Created:** [December 29, 2020, 10:29pm UTC](https://forum.alpaca.markets/t/alpaca-data-api-is-not-observing-start-end-query-parameters/3767 "2020-12-29T22:29:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![synchronicity](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/synchronicity/32/824_2.png) [@synchronicity](https://forum.alpaca.markets/u/synchronicity)
#### Post date: [December 29, 2020, 10:29pm UTC](https://forum.alpaca.markets/t/alpaca-data-api-is-not-observing-start-end-query-parameters/3767/1 "2020-12-29T22:29:39Z")

</div>

Hi Alpaca folks,  
It looks like the [Alpaca Data API](https://alpaca.markets/docs/api-documentation/api-v2/market-data/bars/) has ceased to observe the time bounding parameters `start`/`after` & `end`/`until`.  
I’ve posted twice in the Slack [here](https://alpaca-community.slack.com/archives/CEL9HCSN4/p1609030098442700) & [here](https://alpaca-community.slack.com/archives/CEL9HCSN4/p1609264075465300) but haven’t received any answers.

I’ve tried all kinds of variations on the query parameters for the following URL:

`https://data.alpaca.markets/v1/bars/5Min?symbols=AMZN&limit=999&after=2020-01-05&until=2020-01-07`

Varying the limit, symbols, after, until, start, end do nothing to modify the dates that the API returns - it only returns rows equal to `limit` of the most recent data.

The Alpaca status indicates there’s nothing wrong with the API, but this behavior is very unusual and was not happening just last week.

@hitoshi or others, any ideas?

---

<div class="post-metadata">

### Author: ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)
#### Post date: [December 31, 2020, 4:30pm UTC](https://forum.alpaca.markets/t/alpaca-data-api-is-not-observing-start-end-query-parameters/3767/2 "2020-12-31T16:30:12Z")

</div>

The `bars` API is very sensitive to formatting of the dates. That’s the issue. They must be in ISO format otherwise the API ignores them. Unfortunately, the API doesn’t fail or cause an error if the dates aren’t recognized. Rather, the default date values are used. That is why it seemed varying the dates had no impact on the result. So, try this and you should get the expected results

`https://data.alpaca.markets/v1/bars/5Min?symbols=AMZN&limit=999&after=2020-01-05T09:30:00-04:00&until=2020-01-07T09:30:00-04:00`

There is a bit longer explanation in [this post](https://forum.alpaca.markets/t/get-barset-ignore-start-and-end-dates/2961/2). It’s specifically about the Python SDK (which calls this API) but the basics are the same.

---

<div class="post-metadata">

### Author: ![synchronicity](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/synchronicity/32/824_2.png) [@synchronicity](https://forum.alpaca.markets/u/synchronicity)
#### Post date: [December 31, 2020, 8:03pm UTC](https://forum.alpaca.markets/t/alpaca-data-api-is-not-observing-start-end-query-parameters/3767/3 "2020-12-31T20:03:02Z")

</div>

> [@Dan\_Whitnable\_Alpaca](#):
>
> [https://data.alpaca.markets/v1/bars/5Min?symbols=AMZN&limit=999&after=2020-01-05T09:30:00-04:00&until=2020-01-07T09:30:00-04:00](https://data.alpaca.markets/v1/bars/5Min?symbols=AMZN&limit=999&after=2020-01-05T09:30:00-04:00&until=2020-01-07T09:30:00-04:00)

Thank you @Dan_Whitnable_Alpaca It actually looks like this is an API bug regarding `+` in the offset.

Here’s the query I was using:  
`https://data.alpaca.markets/v1/bars/5Min?symbols=BYND&limit=1000&start=2020-01-06T14:35:00+00:00&end=2020-12-07T15:00:00+00:00`

Which returns the most recent timebars.

This however works:  
`https://data.alpaca.markets/v1/bars/5Min?symbols=BYND&limit=1000&start=2020-01-06T14:35:00-00:00&end=2020-12-07T15:00:00-00:00`

But where does that leave us if we’re actually using a timezone with a positive offset in ISO?

`https://data.alpaca.markets/v1/bars/5Min?symbols=BYND&limit=1000&start=2020-01-06T14:35:00+01:00&end=2020-12-07T15:00:00+01:00`

It falls back to the recent bars again.  
It looks like it’s actually a matter of the API not handling positive offsets! I’m going to workaround this in `AlpacaforR` and just coerce to the `"America/New_York"` timezone for API requests but perhaps this needs to be passed on to the dev team?

Thanks for looking into this!

---

<div class="post-metadata">

### Author: ![synchronicity](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/synchronicity/32/824_2.png) [@synchronicity](https://forum.alpaca.markets/u/synchronicity)
#### Post date: [December 31, 2020, 8:12pm UTC](https://forum.alpaca.markets/t/alpaca-data-api-is-not-observing-start-end-query-parameters/3767/4 "2020-12-31T20:12:26Z")

</div>

While we’re talking API formatting nuances, perhaps you can shed some light on how the JSON ought to look when passing `symbol`s via `POST` method when creating a new `Watchlist`. [Here’s an unanswered thread with the same issue](https://forum.alpaca.markets/t/how-to-add-ticker-symbol-to-watchlist/1966).

I’m currently using the following for a `POST`:

```auto
URL: "https://paper-api.alpaca.markets/v2/watchlists"
Body: {"name":"test","symbol":["MRNA","PFE"]} 

```

as per the [Docs](https://alpaca.markets/docs/api-documentation/api-v2/watchlist#create-a-watchlist).  
Error message explicitly says

> `request body is invalid`

---

<div class="post-metadata">

### Author: ![synchronicity](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/synchronicity/32/824_2.png) [@synchronicity](https://forum.alpaca.markets/u/synchronicity)
#### Post date: [December 31, 2020, 8:26pm UTC](https://forum.alpaca.markets/t/alpaca-data-api-is-not-observing-start-end-query-parameters/3767/5 "2020-12-31T20:26:39Z")

</div>

Looks like after a lot of minor tweaking I figured out that it has to be formatted with line breaks:

```auto
{
	"name": "test",
	"symbols": ["MRNA", "PFE"]
}

```
