Directus (denkhaus) icon

Directus (denkhaus)

Consume Directus API

Overview

This node lists items from a specified collection in a Directus database. It allows you to retrieve, filter, aggregate, and export data from any custom collection. Common use cases include:

  • Fetching all records from a collection for reporting or further processing.
  • Filtering and searching for specific items based on conditions.
  • Exporting data in various formats (CSV, JSON, XML) for sharing or backup.
  • Performing aggregation (e.g., count, sum, average) and grouping results.

Practical examples:

  • Retrieve all articles from the "articles" collection and export them as a CSV file.
  • List users who registered after a certain date, grouped by country.
  • Get the total sales per product category using aggregation functions.

Properties

Name Meaning
Collection Name Unique name of the parent collection to fetch items from. Example: "articles".
Return All Whether to return all results or only up to a given limit. If false, the "Limit" property is used.
Limit Maximum number of results to return (1–100). Only shown if "Return All" is false.
Split Into Items Whether to output each element of an array as its own item in the workflow.
JSON/RAW Parameters Whether query/body parameters should be set via the value-key pair UI or as raw JSON.
Body Parameters Body parameters as JSON or RAW. Used when "JSON/RAW Parameters" is enabled.
Additional Fields A collection of advanced options:
— Aggregate Aggregation functions (count, sum, avg, etc.) to perform calculations on fields. Options: Average, Average Distinct, Count, Count Distinct, Maximum, Minimum, SUM, SUM Distinct.
— Binary Property for Export Data Name of the binary property to download exported data to. Default: "data".
— Deep (JSON) Set nested query parameters for relational datasets as JSON.
— Export Saves the API response to a file. Options: csv, json, xml.
— File Name for Export Data File name for the exported data (without extension). Default: "export".
— Fields Specify which fields to return in the object.
— Filter (JSON) Select items in the collection by given conditions, as JSON.
— Group By Group results by one or more fields (e.g., "author,year(publish_date)").
— Meta Specify what metadata to return in the response.
— Offset How many items to skip when fetching data.
— Search Filter items that contain the given search query in one of their fields.
— Sort How to sort returned items. Use CSV of fields; prefix with minus sign for descending order, or use "?" for random sorting.

Output

  • The node outputs a list of items from the specified collection.
  • Each item is represented as a JSON object containing the fields requested.
  • If "Split Into Items" is enabled, each array element is output as a separate item.
  • If "Export" is used, the data is provided as a binary file (CSV, JSON, or XML) attached to the specified binary property (default: "data").

Example JSON output:

[
  {
    "id": 1,
    "title": "First Article",
    "author": "Alice"
  },
  {
    "id": 2,
    "title": "Second Article",
    "author": "Bob"
  }
]

If exporting, the output will include a binary field with the exported file.

Dependencies

  • Requires access to a Directus instance (API endpoint).
  • May require authentication (API key, token, or credentials configured in n8n).
  • No additional npm dependencies beyond those bundled with the node.

Troubleshooting

  • Invalid Collection Name: If the specified collection does not exist, the node may throw an error such as "Collection not found." Double-check the collection name.
  • Authentication Errors: If credentials are missing or invalid, errors like "Unauthorized" or "401" may occur. Ensure correct API credentials are set up in n8n.
  • Export Errors: If exporting data, ensure the "Binary Property for Export Data" and "File Name for Export Data" are valid strings.
  • Limit Exceeded: If "Limit" is set above the allowed maximum (100), the node may throw a validation error.
  • Malformed JSON: When using JSON/RAW parameters, ensure the JSON syntax is correct to avoid parsing errors.

Links and References

Discussion