Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Directus (DrWade) n8n node for the resource Activity with the operation List allows you to retrieve a list of activity records from a Directus instance. This is useful for monitoring, auditing, or reporting on actions and changes within your Directus-managed data. Common scenarios include:

  • Building dashboards that display recent activities.
  • Auditing user actions for compliance or troubleshooting.
  • Exporting activity logs for external analysis.

Practical examples:

  • Fetch all activity logs for a given period and split them into individual items for further processing in n8n.
  • Retrieve only a limited number of recent activities for a summary notification.
  • Export activity logs as CSV, JSON, or XML files for archival or sharing.

Properties

Name Type Meaning
Return All boolean If enabled, returns all available results; if disabled, limits the number of returned objects according to the "Limit" property.
Limit number The maximum number of activity records to return. Only shown if "Return All" is false. Accepts values between 1 and 100.
Split Into Items boolean If enabled, outputs each element of the resulting array as its own item in n8n, allowing for item-by-item processing.
JSON/RAW Parameters boolean If enabled, query parameters are set via a raw JSON object instead of the UI fields. When true, "Query Parameters" must be provided as JSON.
Query Parameters json A flat JSON object specifying additional query parameters for the API request. Only used when "JSON/RAW Parameters" is true.
Additional Fields collection Allows setting advanced options such as aggregation, export format, filtering, sorting, grouping, and more. See below for details on sub-properties.

Sub-properties of Additional Fields:

  • Aggregate: Specify aggregation functions (e.g., count, sum, avg) and the field to apply them to.
  • Binary Property for Export Data: Name of the binary property to store exported file data.
  • Deep (JSON): Set nested query parameters for related datasets.
  • Export: Choose to export the response as a file (CSV, JSON, XML).
  • Fields: Control which fields are returned in the response.
  • File Name for Export Data: File name (without extension) for exported data.
  • Filter (JSON): Filter conditions as a JSON object.
  • Group By: Group results by specified fields.
  • Meta: Specify what metadata to include in the response.
  • Offset: Number of items to skip (for pagination).
  • Search: Search string to filter items.
  • Sort: Sorting instructions as a CSV string.

Output

  • json:
    • If "Split Into Items" is enabled and the response is an array, each item will be output as a separate n8n item under the json property.
    • Otherwise, the full response (or the data field from the API response) is output as a single item under the json property.
    • If "Export" is used, the output may also include a binary property containing the exported file (CSV, JSON, or XML), with the file named and typed according to the selected options.

Example output structure:

{
  "json": {
    // Activity record fields as returned by Directus
  }
}

If exporting:

{
  "json": { /* summary or metadata */ },
  "binary": {
    "data": {
      "data": "<Buffer ...>",
      "fileName": "export.csv",
      "mimeType": "text/csv"
    }
  }
}

Dependencies

  • External Service: Requires access to a Directus instance with API credentials.
  • API Key/Credentials: You must configure the directusApi credential in n8n.
  • Environment: No special environment variables required beyond n8n's standard configuration.

Troubleshooting

Common issues:

  • Invalid Credentials: If the Directus API credentials are incorrect or missing, authentication errors will occur.
  • Malformed JSON: If using "JSON/RAW Parameters" or providing filters/deep/groupBy as JSON, ensure the JSON is valid. Malformed JSON will cause parsing errors.
  • Export Errors: If "Export" is selected but the response is not compatible (e.g., trying to export non-array data as CSV), the export may fail or produce empty files.
  • Limit Exceeded: If "Limit" is set above the allowed maximum (100), the node may throw an error or default to the maximum allowed by Directus.

Error messages and resolutions:

  • "Unexpected token ... in JSON": Check that all JSON input fields contain valid JSON.
  • "Missing required parameter": Ensure all required properties (like "Return All" or "Limit") are set appropriately.
  • "Request failed with status code 401": Verify your Directus API credentials.

Links and References

Discussion