Directus icon

Directus

Consume Directus API

Overview

This node interacts with the Directus API to manage "Folders" resources, specifically supporting the List operation. It retrieves a list of folders from a Directus instance, allowing users to fetch all folders or limit the number of results returned. The node supports advanced query customization, including filtering, sorting, grouping, and aggregation.

Common scenarios where this node is beneficial include:

  • Retrieving all folder metadata for content organization in a headless CMS.
  • Fetching a subset of folders based on specific criteria (e.g., parent folder, creation date).
  • Exporting folder data in various formats (JSON, CSV, XML) for reporting or backup.
  • Integrating folder information into automated workflows that require folder structure awareness.

Practical example:

  • A user wants to get all folders containing media assets to synchronize them with an external DAM system.
  • Another use case is listing folders with aggregated counts of files inside each folder.

Properties

Name Meaning
Return All Boolean flag to return all folder results or limit the output to a specified number.
Limit Number specifying the maximum number of folder objects to return when "Return All" is false. Range: 1 to 100.
Split Into Items Boolean indicating whether to output each folder as a separate item or as a single array.
JSON/RAW Parameters Boolean to choose between entering query parameters via UI fields or directly as raw JSON.
Query Parameters JSON object representing query parameters for filtering, sorting, pagination, etc., used if "JSON/RAW Parameters" is true.
Additional Fields Collection of optional fields to customize the query, including:
- Aggregate Aggregation functions like count, sum, average, min, max applied on folder fields.
- Binary Property for Export Data String name of the binary property where exported file data will be stored.
- Deep (JSON) JSON object for nested relational dataset queries.
- Export Option to export the API response as a file in one of these formats: json, csv, or xml.
- Fields Comma-separated string to specify which folder fields to return.
- File Name for Export Data Filename (without extension) for the exported data file.
- Filter (JSON) JSON object defining conditions to filter the folders collection.
- Group By String to group results by specified field(s), enabling grouped aggregation (e.g., "author", "year(publish_date)").
- Meta String specifying what metadata to include in the response.
- Offset Number of items to skip before starting to collect the result set (pagination offset).
- Search String to filter folders containing the search query in any of their fields.
- Sort CSV string defining sort order of returned folders. Prefix a field with - for descending order; default is ascending. Use ? for random sorting.

Output

The node outputs JSON data representing the folders retrieved from the Directus API. The structure corresponds to the folder objects as defined by Directus, typically including properties such as folder ID, name, parent folder, creation date, and other metadata.

If the "Split Into Items" option is enabled, each folder is output as a separate item; otherwise, all folders are output as a single array.

When 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 accessible under the specified binary property name (default "data"), allowing downstream nodes to handle the file (e.g., save to disk, upload).

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 related to folders.
  • No additional external dependencies beyond the Directus API and n8n's HTTP request capabilities.

Troubleshooting

  • Authentication errors: Ensure the API key credential is correctly configured and has sufficient permissions to access folders.
  • Invalid JSON in parameters: When using JSON/RAW parameters, ensure the JSON syntax is correct to avoid parsing errors.
  • Limit exceeded: The API enforces a maximum limit of 100 items per request; requesting more without "Return All" enabled may cause errors.
  • Export issues: If exporting data, verify that the chosen format is supported and that the filename does not contain invalid characters.
  • Empty results: Check filters, search queries, and other parameters to ensure they match existing folders.
  • API rate limits: Frequent requests might hit API rate limits; consider adding delays or handling retries.

Links and References

Discussion