How do I download the last few rows of a time-series using Python?
Note that each data feed on Nasdaq Data Link is delivered through one of the following Nasdaq Data Link APIs:
- Streaming API for real-time data
- REST API for real-time or delayed data
- REST API for time-series
- REST API for tables
You can learn more about these APIs and data formats here.
The Nasdaq Data Link Python package may only be used with data delivered through the REST API for time-series or the REST API for tables. Please do not confuse this package with the Python SDK for the streaming API.
If you are using time-series data with the Nasdaq Data Link Python package, and want the last few rows from an individual time-series, use the rows= parameter to get only the most recent rows of data. For example, if you are using the NASDAQ Stock Market Prices (XNAS) data feed and want the latest 5 rows for the AAPL time-series, you can use a Python command like this:
data = nasdaqdatalink.get("XNAS/ACIW", rows=5, sort_order="desc")
The above command will return the latest 5 rows from the XNAS/ACIW time-series in descending order because rows=5 and sort_order="desc".
To see other parameters for individual time-series, please see the documentation here. To see other examples of Python commands for time-series data, please see here.