Directus (flagbit) icon

Directus (flagbit)

Consume Directus API

Overview

This node is designed to retrieve settings data from a system, supporting flexible querying and exporting options. It allows users to fetch settings with various filters, sorting, grouping, and aggregation functions applied. The node is useful in scenarios where you need to programmatically access configuration or metadata settings, analyze them with aggregate calculations, or export the results in different file formats such as CSV, JSON, or XML.

Practical examples include:

  • Fetching specific settings filtered by certain criteria.
  • Aggregating counts or averages of particular setting fields grouped by categories.
  • Exporting the retrieved settings data for reporting or backup purposes.

Properties

Name Meaning
JSON/RAW Parameters Whether to input query and/or body parameters via UI key-value pairs or directly as JSON/RAW.
Query Parameters Query parameters as a flat JSON object (used if JSON/RAW Parameters is true).
Additional Fields Collection of optional fields to customize the request:
- Aggregate Aggregation functions to perform calculations on sets of values, returning single results. Functions include Average, Average Distinct, Count, Count Distinct, Maximum, Minimum, SUM, SUM Distinct. Field to apply aggregation on can be selected.
- Binary Property for Export Data Name of the binary property where exported data will be saved.
- Deep (JSON) Nested relational dataset parameters allowing deep queries on related data.
- Export Format to save the API response file: CSV, JSON, or XML.
- File Name for Export Data Filename (without extension) for the exported data file.
- Fields Comma-separated list of fields to return in the response objects.
- Filter (JSON) JSON object specifying conditions to filter items in the collection.
- Group By Fields to group results by, enabling aggregation per group (e.g., "author", "year(publish_date)").
- Meta Metadata fields to include in the response.
- Offset Number of items to skip when fetching data (for pagination).
- Search Text query to filter items containing the search string in any field.
- Sort CSV of fields to sort the returned items by. Prefix with "-" for descending order, default is ascending. Use "?" for random sorting.

Output

The node outputs the fetched settings data in the json output field. This data structure contains an array of objects representing the settings matching the query parameters and filters applied.

If the user chooses to export the data, the node saves the response in a binary property named as specified (default "data"), containing the exported file in the chosen format (CSV, JSON, or XML). This binary data can then be used downstream for file download or further processing.

Dependencies

  • Requires connection to the target system's API that provides the settings data.
  • Needs appropriate API authentication credentials configured in n8n to authorize requests.
  • No additional external libraries are indicated beyond those bundled internally.

Troubleshooting

  • Invalid JSON in Query Parameters or Filters: If JSON input is malformed, the node may fail. Validate JSON syntax before execution.
  • Incorrect Field Names: Using invalid field names in filters, groupings, or aggregations can cause errors or empty results. Verify field names exist in the target dataset.
  • Export Failures: Ensure the file name does not contain invalid characters and the export format is supported.
  • Authentication Errors: Missing or incorrect API credentials will prevent data retrieval. Confirm credentials are set up correctly.
  • Large Data Sets: Fetching large volumes without proper offset or limits may lead to timeouts or memory issues. Use pagination parameters like offset carefully.

Links and References

Discussion