Directus icon

Directus

Consume Directus API

Overview

This node interacts with the Directus API to retrieve or manipulate settings data. Specifically, the "Settings" resource with the "Get" operation allows users to fetch configuration or system settings from a Directus instance.

Common scenarios where this node is beneficial include:

  • Retrieving current system or application settings for monitoring or auditing.
  • Exporting settings data for backup or migration purposes.
  • Filtering or querying specific settings based on criteria.

Practical example:

  • A user wants to get all system settings and export them as a JSON file for documentation or version control.
  • Another use case could be fetching filtered settings that match certain conditions to dynamically adjust workflows.

Properties

Name Meaning
JSON/RAW Parameters Boolean flag to choose whether query parameters are set via UI key-value pairs (false) or by providing raw JSON (true).
Query Parameters When JSON/RAW Parameters is true, this JSON object defines the query parameters to send with the request.
Additional Fields Collection of optional fields to customize the request when not using raw JSON. Includes:
- Aggregate functions (count, sum, average, min, max, etc.) applied on specified fields.
- Binary property name for export data.
- Deep (nested relational dataset) JSON.
- Export format (json, csv, xml).
- Fields to return.
- File name for export.
- Filter conditions in JSON.
- Group By fields.
- Meta information to return.
- Offset for pagination.
- Search string.
- Sort order.
Binary Property for Export Data Name of the binary property where exported data will be saved if export is enabled. Defaults to "data".
Deep (JSON) JSON object to specify nested relational query parameters.
Export Option to save the API response to a file in one of these formats: csv, json, or xml.
Fields String to control which fields are returned in the response.
File Name for Export Data Filename (without extension) used when exporting data to a file. Defaults to "export".
Filter (JSON) JSON object specifying conditions to filter items in the collection.
Group By String specifying fields to group results by, enabling aggregation functions per group.
Meta String specifying what metadata to include in the response.
Offset Number of items to skip when fetching data (pagination offset).
Search String to filter items containing this search query in any field.
Sort CSV string defining sort order of returned items. Prefix a field with - for descending order, or use ? for random sorting.

Output

The node outputs the fetched settings data in the json field of the output items. The structure corresponds directly to the response from the Directus API's settings endpoint.

If the Export option is selected, the node also outputs the data as a binary file under the specified binary property name (default "data"). This binary data contains the API response serialized into the chosen format (json, csv, or xml), suitable for download or further processing.

Dependencies

  • Requires an active connection to a Directus instance via an API key credential configured in n8n.
  • The node uses the Directus REST API endpoints for settings.
  • No additional external dependencies beyond the Directus API and n8n environment.

Troubleshooting

  • Invalid JSON in Query Parameters or Filters: If raw JSON input is malformed, the node will throw a parsing error. Ensure JSON syntax is correct.
  • API Authentication Errors: If the API key or credentials are invalid or expired, requests will fail with authentication errors. Verify and update credentials.
  • Unsupported Export Format: Selecting an unsupported export format may result in empty or failed binary data creation. Use only json, csv, or xml.
  • Large Data Sets: Fetching large numbers of settings without pagination (limit or returnAll) may cause timeouts or memory issues. Use pagination options appropriately.
  • Incorrect Field Names in Aggregations or Filters: Using non-existent fields in aggregation or filters can cause API errors. Validate field names against your Directus schema.

Links and References

Discussion