Directus (denkhaus) icon

Directus (denkhaus)

Consume Directus API

Overview

This node retrieves a list of roles from a Directus v1 API. It is designed to fetch role data, supporting advanced filtering, sorting, aggregation, and export options. Common scenarios include:

  • Listing all user roles for administrative or reporting purposes.
  • Exporting role data in various formats (CSV, JSON, XML) for backup or integration with other systems.
  • Filtering, grouping, or aggregating roles based on specific criteria.

Practical examples:

  • Fetch all roles and export them as a CSV file for HR review.
  • Retrieve only roles that match certain search terms or filters.
  • Aggregate roles by type and count how many users are assigned to each.

Properties

Name Meaning
Return All Whether to return all results or only up to a given limit. If disabled, the "Limit" property controls the maximum number of results.
Limit Max number of results to return (only shown if "Return All" is false). Accepts values between 1 and 100.
Split Into Items Whether to output each element of an array as its own item. Useful for downstream processing in n8n.
JSON/RAW Parameters Whether the query and/or body parameter should be set via the value-key pair UI or as raw JSON.
Body Parameters Body parameters as JSON or RAW (shown if "JSON/RAW Parameters" is enabled). Allows advanced users to specify request body directly.
Additional Fields Collection of extra options to refine the query, including:
- Aggregate Aggregation functions to perform calculations on a set of values. Options: Average, Average Distinct, Count, Count Distinct, Maximum, Minimum, SUM, SUM Distinct.
- Binary Property for Export Data Name of the binary property to download the exported data to. Default is "data".
- Deep (JSON) Set additional query parameters on nested relational datasets using 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 is "export".
- Fields Control which fields are returned in the object. Accepts a comma-separated list.
- Filter (JSON) Select items in the collection by given conditions, specified as JSON.
- Group By Grouping allows running aggregation functions based on shared values (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 by items containing the given search query in one of their fields.
- Sort How to sort the returned items. Accepts a CSV of fields; use minus sign (-) for descending order, or ? for random sorting.

Output

  • The node outputs a JSON array of role objects, each representing a role retrieved from Directus.
  • If "Split Into Items" is enabled, each role will be output as a separate item.
  • If "Export" is used, the node can output binary data (e.g., CSV, JSON, or XML file) under the specified binary property name.

Dependencies

  • Requires access to a Directus v1 API endpoint.
  • May require authentication credentials (API key, token, or username/password) depending on your Directus setup.
  • n8n must be configured to allow HTTP requests to the Directus instance.

Troubleshooting

  • Common issues:

    • Incorrect API credentials or endpoint URL may result in authentication errors.
    • Using invalid filter or aggregation syntax in JSON fields can cause request failures.
    • Setting "Limit" above the allowed maximum (100) will likely result in validation errors.
    • Exporting large datasets may hit memory or timeout limits.
  • Error messages and resolutions:

    • 401 Unauthorized: Check your API credentials and permissions.
    • 400 Bad Request: Review your filter, aggregation, or field selection for syntax errors.
    • 413 Payload Too Large: Reduce the amount of data requested or increase server limits.

Links and References

Discussion