Directus (flagbit) icon

Directus (flagbit)

Consume Directus API

Overview

This node is designed to list items from a specified collection within a data source, supporting advanced querying capabilities. It is useful when you want to retrieve multiple records with filtering, sorting, grouping, and aggregation options. Typical use cases include fetching articles, products, or any custom entities stored in collections for further processing or analysis.

For example, you might use this node to:

  • Retrieve all articles from a blog collection.
  • Get the top 50 products sorted by sales.
  • Aggregate user data to find average ratings per category.
  • Export queried data as CSV or JSON files.

Properties

Name Meaning
Collection Name Unique name of the parent collection from which to list items.
Return All Whether to return all results or only up to a given limit.
Limit Maximum number of results to return (used if "Return All" is false). Range: 1 to 100.
Split Into Items Whether to output each element of an array as its own separate item.
JSON/RAW Parameters Whether query and/or body parameters should be set via UI key-value pairs or as raw JSON input.
Body Parameters Body parameters provided as JSON or RAW text (used if JSON/RAW Parameters is true).
Additional Fields Extra optional fields to customize the request, including:
- Aggregate Aggregation functions to perform calculations on sets of values, such as count, sum, average, min, max, etc.
- Binary Property for Export Data Name of the binary property where exported data will be saved.
- Deep (JSON) Nested relational dataset parameters for deep querying.
- Export Format to save the API response file: CSV, JSON, or XML.
- File Name for Export Data Filename (without extension) for the exported data file.
- Fields Comma-separated list of fields to control which fields are returned in the objects.
- Filter (JSON) JSON object defining conditions to filter items in the collection.
- Group By Field(s) to group results by, enabling aggregation per group (e.g., "author", "year(publish_date)").
- Meta Metadata fields to include in the response.
- Offset Number of items to skip before starting to fetch data (for pagination).
- Search Text query to filter items containing the search string in any field.
- Sort Comma-separated list of fields to sort by. Prefix with "-" for descending order; "?" for random sorting.

Output

The node outputs a JSON array of items retrieved from the specified collection according to the applied filters, sorting, and limits. Each item corresponds to a record in the collection and includes the requested fields.

If export is enabled, the node also outputs a binary file containing the data in the selected format (CSV, JSON, or XML), accessible via the specified binary property name.

Dependencies

  • Requires connection to a backend service that manages collections and items (likely an API).
  • Needs appropriate authentication credentials (e.g., an API key or token) configured in n8n to access the data source.
  • The node depends on internal methods for loading options and routing requests but does not require external npm packages beyond those bundled.

Troubleshooting

  • Empty Results: Ensure the collection name is correct and that filters/search queries match existing data.
  • Limit Ignored: If "Return All" is true, the limit setting is ignored; set "Return All" to false to enforce limits.
  • Invalid JSON in Parameters: When using JSON/RAW parameters, ensure valid JSON syntax to avoid parsing errors.
  • Export File Not Created: Verify that the export option is set and that the binary property name is correctly specified.
  • API Authentication Errors: Confirm that the API credentials are properly configured and have sufficient permissions to read the collection.

Links and References

Discussion