Filter & Sort API Responses: Data Output Example
Query Parameters
To make your data processing more efficient, you can use query parameters to select specific columns, sort the results, handle pagination, and download the data directly as a CSV file.
Parameters used: columns, sort, limit, and response_format.
What it does: Modifies the API request to return a targeted, sorted subset of data and saves it locally. We use the -o flag in curl to output the response directly to a file.
Request example (Saving a customized CSV file):
curl --get \
'https://api.algoseek.com/v1/data/us-equity/taq/2023-03-01/AAPL' \
--data-urlencode 'columns=EventDateTime,EventType,Price,Quantity' \
--data-urlencode 'sort=-EventDateTime' \
--data-urlencode 'limit=500' \
--data-urlencode 'response_format=csv' \
-H "X-API-KEY: YOUR_API_KEY" \
-o "aapl_custom_taq.csv"
Column Filtering (columns)
By default, the API returns all available fields for a given dataset. To reduce payload size and parsing time, use the columns parameter to request only the specific data points your model requires.
Financial datasets often contain dozens of columns per record. If your model only needs a few specific fields, use the columns query parameter to reduce payload size and speed up the transfer.
Provide a comma-separated list of the exact column names you wish to retrieve. If not provided, the API will return all available columns.
- Syntax: A comma-separated list of exact column names (case-sensitive).
Example Request:
curl --get \
'https://api.algoseek.com/v1/data/us-equity/taq/2023-03-01/AAPL' \
--data-urlencode 'columns=TradeDate,EventDateTime,Ticker,Price,Quantity' \
-H "X-API-KEY: YOUR_API_KEY"
Example Response:
{
"data": [
{
"TradeDate": "2023-03-01",
"EventDateTime": "2023-03-01 03:59:00.051594605",
"Price": 0,
"Quantity": 0
},
{
"TradeDate": "2023-03-01",
"EventDateTime": "2023-03-01 03:59:00.051594605",
"Price": 0,
"Quantity": 0
},
{
"TradeDate": "2023-03-01",
"EventDateTime": "2023-03-01 03:59:00.051594605",
"Price": 0,
"Quantity": 0
},
...
],
"pagination": {
"offset": 0,
"limit": 1000,
"next_offset": 1000
}
}
Sorting (sort)
The sort parameter allows you to define the ordering of the returned records. Depending on the dataset, multiple sorting fields may be supported.
- Ascending Order: Prefix the column name with
+(or provide the column name with no prefix). - Descending Order: Prefix the column name with
-. - Multiple Columns: Provide a comma-separated list. The sort is applied in the order the fields are listed.
Example Request (Sort by descending Date, then ascending ClosePrice):
curl --get \
'https://api.algoseek.com/v1/data/us-equity/daily-ohlc/AAPL' \
--data-urlencode 'sort=-TradeDate,+ClosePrice' \
-H "X-API-KEY: YOUR_API_KEY"
Define the period (period)
The period query parameter limits how much historical data is returned relative to the current or specified date. You can query the period of data by using the Y, W, and D units:
period=5D(5 days)period=1W(1 week)period=7Y(7 years)
To optimize the response time, we use the following period defaults:
period=5Y- 5 years for smaller datasets (trade-only minute bars, daily data, or reference data)period=1Y- 1 year for heavy datasets (trade and quote extended bars)
Example Request:
curl --get \
'https://api.algoseek.com/v1/data/us-equity/daily-ohlc/AAPL' \
--data-urlencode 'period=3D' \
-H "X-API-KEY: YOUR_API_KEY"