# Historical intraday volume specific data

**URL:** https://forum.alpaca.markets/t/historical-intraday-volume-specific-data/3083
**Category:** Alpaca Market Data
**Created:** [October 22, 2020, 12:14am UTC](https://forum.alpaca.markets/t/historical-intraday-volume-specific-data/3083 "2020-10-22T00:14:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Limited\_Edition](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/limited_edition/32/1457_2.png) [@Limited\_Edition](https://forum.alpaca.markets/u/Limited_Edition)
#### Post date: [October 22, 2020, 12:14am UTC](https://forum.alpaca.markets/t/historical-intraday-volume-specific-data/3083/1 "2020-10-22T00:14:10Z")

</div>

Hi all,  
Is there a way to get the specific 5 minute volume total for a specific stock at a specific time? For example AAPL 10/21 10:45am?

If so, could you point me in the right direction in the documentation? I’ve looked but could only see daily volume.

Thanks!

---

<div class="post-metadata">

### Author: ![dan\_whitnable](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable/32/1323_2.png) [@dan\_whitnable](https://forum.alpaca.markets/u/dan_whitnable)
#### Post date: [October 23, 2020, 2:52pm UTC](https://forum.alpaca.markets/t/historical-intraday-volume-specific-data/3083/2 "2020-10-23T14:52:12Z")

</div>

Yes, one can get specific 5 minute volume data a couple of ways. The first is using the Alpaca API which uses IEX (Investors Exchange LLC) data. The second is using Polygon data. There is information on the differences in the [docs](https://alpaca.markets/docs/api-documentation/api-v2/market-data/). Basically, IEX data is available to all Alpaca users but doesn’t include trades from all exchanges (so volume, for example, may be less than the total traded across all exchanges/venues). Polygon data is aggregated across all exchanges but one needs a live account to access the data.

The info on the low level API for IEX data is [here](https://alpaca.markets/docs/api-documentation/api-v2/market-data/bars/) and the Polygon data is [here](https://polygon.io/docs/#get_v2_ticks_stocks_trades __ticker___ date__anchor).

Alpaca includes ‘wrappers’ making it easier to use the low level API. The Python version can be found (and imported) [here](https://github.com/alpacahq/alpaca-trade-api-python/blob/master/alpaca_trade_api/rest.py). I find the best way to see how to use a specific method is to look at the actual code. In this case, to fetch IEX data using python, one uses the `get_barset` method. The code showing how to use this method is [here](https://github.com/alpacahq/alpaca-trade-api-python/blob/cd22b3393aff8df214d867b6a4723a21ea34a3c0/alpaca_trade_api/rest.py#L410). If one wants to use Polygon data then use the `historic_trades_v2` method. There’s info on that [here](https://github.com/alpacahq/alpaca-trade-api-python/blob/cd22b3393aff8df214d867b6a4723a21ea34a3c0/alpaca_trade_api/polygon/rest.py#L109).

So, as an example, in Python the code to get 5 minute volume for AAPL on 10/21/2020 at 10:45am would look like this

```
data = api.get_barset('AAPL', 
                      '5Min', 
                      start='2020-10-21T10:45:00-04:00', 
                      end='2020-10-21T10:45:00-04:00',
                     )
# Turn the data into a dataframe for easier manipulation
data_df = data.df

# Get just the volume data for AAPL
aapl_volume = data_df['AAPL'].volume

```

The Polygon data can be fetched like this

```
poly_data = api.polygon.historic_agg_v2(symbol= 'AAPL', 
                            multiplier=5, 
                            timespan='minute', 
                            _from='2020-10-21T10:45:00-04:00', 
                            to='2020-10-21T10:45:00-04:00')

# Turn the data into a dataframe for easier manipulation
poly_data_df = poly_data.df

# Polygon data can't be specified to the minute (even though it's given as a parameter)
# It will return the entire days data.
# So one needs to fetch just the time on wants from the dataframe
aapl_volume = poly_data_df.between_time('10:45', '10:45').volume

```

Hope that starts you in the right direction. Good luck.

---

<div class="post-metadata">

### Author: ![Quant\_Street](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/quant_street/32/2352_2.png) [@Quant\_Street](https://forum.alpaca.markets/u/Quant_Street)
#### Post date: [March 19, 2021, 1:26am UTC](https://forum.alpaca.markets/t/historical-intraday-volume-specific-data/3083/3 "2021-03-19T01:26:54Z")

</div>

This is not working…  
It seems my Alpaca API key is being passed to Polygon API for those API calls.

Given the Polygon is the only way to get historical data with adjusted prices, this makes long term price analysis impossible.
