Actions109
- Activity Actions
- Assets Actions
- Authentication Actions
- Collections Actions
- Extensions Actions
- Fields Actions
- Files Actions
- Folders Actions
- Items Actions
- Permissions Actions
- Presets Actions
- Relations Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
- Webhooks Actions
Overview
This node interacts with the Directus API to list items from a specified collection. It is designed to fetch data records (items) stored in a particular collection within a Directus-managed database. The node supports advanced querying capabilities such as filtering, sorting, pagination, aggregation, and exporting results in various formats.
Common scenarios where this node is beneficial include:
- Retrieving all or a subset of records from a content collection for further processing or integration.
- Exporting data from Directus collections into JSON, CSV, or XML files.
- Performing aggregated queries like counts, sums, averages grouped by specific fields.
- Fetching deeply nested relational data using JSON parameters.
- Splitting array responses into individual output items for downstream nodes.
Practical example:
- You want to get all articles from a "blog_posts" collection, sorted by publish date descending, limited to 50 entries, and export the result as a CSV file for reporting purposes.
- Or you need to count how many unique authors have contributed to a collection and group the results by author name.
Properties
| Name | Meaning |
|---|---|
| Collection | Unique name of the parent collection from which to list items. |
| Return All | Boolean flag indicating whether to return all matching results or limit the number of returned objects. |
| Limit | Maximum number of objects to return when "Return All" is false. Must be between 1 and 100. |
| Split Into Items | If true, outputs each element of the returned array as its own separate item; otherwise, outputs the entire array as one item. |
| JSON/RAW Parameters | If true, query parameters are set via a JSON/raw input instead of UI key-value pairs. |
| Query Parameters | JSON object specifying query parameters for filtering, sorting, pagination, etc., used when "JSON/RAW Parameters" is true. |
| Additional Fields | Collection of optional additional parameters including: |
| - Aggregate: Aggregation functions (count, sum, average, min, max, distinct variants) applied on specified fields. | |
| - Binary Property for Export Data: Name of the binary property to store exported file data. | |
| - Deep (JSON): Nested relational dataset query parameters as JSON. | |
| - Export: Format to save API response to a file (json, csv, xml). | |
| - Fields: Comma-separated string controlling which fields to return. | |
| - File Name for Export Data: Base filename for exported data without extension. | |
| - Filter (JSON): JSON object defining conditions to filter items in the collection. | |
| - Group By: String defining grouping fields for aggregation functions. | |
| - Meta: Metadata to include in the response. | |
| - Offset: Number of items to skip when fetching data (pagination offset). | |
| - Search: Text query to filter items containing the given string in any field. | |
| - Sort: CSV string defining sort order of returned items. Prefix fields with "-" for descending order, or use "?" for random sorting. |
Output
The node outputs JSON data representing the fetched items from the specified collection. The structure of the json output corresponds directly to the data returned by the Directus API for the requested collection and query parameters.
If the "Split Into Items" option is enabled, each item in the returned array is output as an individual item in the workflow.
If the "Export" option is used, the node also outputs binary data containing the exported file in the selected format (JSON, CSV, or XML). This binary data is available under the specified binary property name (default "data"), allowing subsequent nodes to handle file downloads or uploads.
Dependencies
- Requires a valid connection to a Directus instance via an API key credential configured in n8n.
- The node uses the Directus REST API endpoints to perform operations.
- No additional external dependencies beyond the Directus API and n8n's HTTP request capabilities.
Troubleshooting
- Invalid Collection Name: If the specified collection does not exist or is misspelled, the API will return an error. Verify the collection name using the "Collection" dropdown or ensure it matches your Directus setup.
- Authentication Errors: Ensure the API key credential is correctly configured and has sufficient permissions to read items from the collection.
- Malformed JSON Parameters: When using JSON/RAW parameters, invalid JSON syntax will cause parsing errors. Validate JSON inputs carefully.
- Limit Exceeded: The "Limit" property must be between 1 and 100. Setting values outside this range may cause errors.
- Export Issues: If exporting data, ensure the file name and binary property names are valid strings. Also, large exports might impact performance.
- Aggregation Misconfiguration: Incorrect aggregation function names or fields can lead to API errors. Use the provided options to select valid functions and fields.
- Network or API Downtime: Network issues or Directus server downtime will cause request failures. Check connectivity and server status.