-
Notifications
You must be signed in to change notification settings - Fork 0
Intraday Data
The Intraday endpoint provides near real-time stock data with intervals ranging from 1 minute to 1 hour. This feature is available on paid Marketstack plans and is essential for applications that require up-to-the-minute market information.
To access intraday data, use the intraday() method on the Marketstack facade. You can specify the time interval and filter the data by date and exchange.
The interval() method allows you to specify the time granularity of the data. The available options are 1min, 5min, 10min, 15min, 30min, and 1hour.
use Tigusigalpa\Marketstack\Facades\Marketstack;
$intraday = Marketstack::intraday()
->symbols('TSLA')
->interval('1h')
->dateFrom('2023-01-15')
->dateTo('2023-01-15')
->collect();To get the most recent intraday data, use the latest() method:
$latest = Marketstack::intraday()
->symbols('TSLA')
->interval('5min')
->latest()
->dto();
echo "Last price: {$latest->last}";You can also filter intraday data by the stock exchange's MIC code:
$filtered = Marketstack::intraday()
->symbols('AAPL')
->exchange('XNAS')
->interval('1hour')
->limit(50)
->collect();The following methods are available for the Intraday endpoint:
| Method | Description |
|---|---|
symbols(string ...$symbols) |
A list of stock symbols to retrieve data for. |
interval(string $interval) |
The time interval (1min, 5min, 10min, 15min, 30min, 1hour). |
dateFrom(string $date) |
The start date for the data range (YYYY-MM-DD). |
dateTo(string $date) |
The end date for the data range (YYYY-MM-DD). |
latest() |
Get the latest intraday data for the specified symbols. |
exchange(string $exchange) |
Filter by the MIC code of the stock exchange. |
limit(int $limit) |
The number of results to return. |
offset(int $offset) |
The pagination offset. |
For more information on response formats, see the Response Formats page.