Directus icon

Directus

Consume Directus API

Overview

The Directus node for n8n, when configured with the Resource: Settings and Operation: Get, retrieves the current global settings from a Directus instance. This operation is useful for automating audits, synchronizing configuration across environments, or integrating system settings into other workflows.

Practical scenarios include:

  • Fetching all Directus project settings for backup or documentation.
  • Exporting settings to a file (CSV, JSON, XML) for migration or compliance purposes.
  • Filtering or aggregating settings data for reporting or monitoring.

Properties

Name Type Meaning
JSON/RAW Parameters boolean If enabled, allows you to provide query parameters as a raw JSON object instead of using the UI fields.
Query Parameters json (Shown if JSON/RAW Parameters is true) The query parameters as a flat JSON object, directly passed to the API request.
Additional Fields collection (Shown if JSON/RAW Parameters is false) A set of optional fields to further customize the request. See below for details.

Additional Fields options:

  • Aggregate: Specify aggregation functions (e.g., count, sum, avg) to perform calculations on settings data.
  • Binary Property for Export Data: Name of the binary property where exported file data will be stored.
  • Deep (JSON): Set nested query parameters for related datasets.
  • Export: Choose to export the response as a file in CSV, JSON, or XML format.
  • Fields: Control which fields are returned in the response.
  • File Name for Export Data: File name (without extension) for the exported data.
  • Filter (JSON): Filter settings by specific conditions.
  • Group By: Group results by specified fields for aggregation.
  • Meta: Specify what metadata to return in the response.
  • Offset: Number of items to skip (for pagination).
  • Search: Search query to filter settings.
  • Sort: Sort order for the returned settings.

Output

  • The node outputs an array of objects under the json field, each representing a settings record from Directus.
  • If the Export option is used, the output will also include a binary field containing the exported file (CSV, JSON, or XML), with the property name as specified in "Binary Property for Export Data".

Example output (no export):

[
  {
    "json": {
      "project_name": "My Directus Project",
      "public_url": "https://example.com",
      "...": "..."
    }
  }
]

Example output (with export):

[
  {
    "json": { /* settings data */ },
    "binary": {
      "data": {
        "data": "<Buffer ...>",
        "fileName": "export.json",
        "mimeType": "application/json"
      }
    }
  }
]
  • The structure of the json object depends on the fields selected and any filters applied.
  • If multiple records are returned (rare for settings), each will be a separate item in the output array.

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n with appropriate permissions to read settings.
  • No additional environment variables are required beyond standard n8n and Directus setup.

Troubleshooting

Common issues:

  • Authentication errors: Ensure your API credentials are correct and have permission to access settings.
  • Invalid JSON in parameters: When using JSON/RAW mode, malformed JSON will cause errors. Double-check your syntax.
  • Empty or unexpected output: Check that your filters or fields selection are not too restrictive.
  • Exported file missing or empty: Ensure the "Binary Property for Export Data" and "Export" options are set correctly.

Error messages:

  • "Unexpected token ... in JSON": Indicates invalid JSON input; fix the formatting.
  • "Request failed with status code 401": Authentication issue; check credentials.
  • "Cannot read property 'data' of undefined": Likely due to an unexpected API response; verify Directus API availability and endpoint correctness.

Links and References

Discussion