Directus (flagbit) icon

Directus (flagbit)

Consume Directus API

Overview

The node provides functionality to list "Activity" records from a data source, supporting flexible querying and output options. It is useful for retrieving activity logs, audit trails, or event histories in applications where tracking changes or user actions is important. For example, it can be used to fetch all recent activities of users on a platform, filter activities by type or date, aggregate statistics like counts or averages, and export the results in various formats such as JSON, CSV, or XML.

Properties

Name Meaning
Return All Whether to return all matching results or limit the number of returned items.
Limit Maximum number of results to return when not returning all. Value between 1 and 100.
Split Into Items Whether to output each element of an array as its own separate item in the workflow output.
JSON/RAW Parameters Whether to provide query and body parameters via UI fields or as raw JSON input.
Body Parameters Raw JSON or RAW string specifying body parameters for the request (used if JSON/RAW Parameters is true).
Additional Fields Collection of optional additional parameters:
- Aggregate Aggregation functions to perform calculations on fields, e.g., count, average, sum, min, max, distinct variants. Multiple aggregation functions can be specified.
- Binary Property for Export Data Name of the binary property to store exported file data.
- Deep (JSON) Nested relational dataset parameters as JSON for deep querying.
- Export Format to save API response to a file: JSON, CSV, or XML.
- File Name for Export Data Filename (without extension) for the exported data file.
- Fields Comma-separated list of fields to include in the returned objects.
- Filter (JSON) JSON object specifying conditions to filter the collection items.
- Group By Field(s) to group results by for aggregation purposes, e.g., "author", "year(publish_date)".
- Meta Metadata fields to include in the response.
- Offset Number of items to skip before starting to return results (for pagination).
- Search Text query to filter items containing the given search term in any field.
- Sort Comma-separated list of fields to sort by. Prefix with "-" for descending order, "?" for random sorting.

Output

The node outputs JSON data representing the list of activity records retrieved according to the specified filters and options. The structure corresponds to the queried fields and may include aggregated values if aggregation functions are used. If the "Split Into Items" option is enabled, each array element is output as a separate item in the workflow.

If export is enabled, the node outputs the API response saved as a file in the selected format (JSON, CSV, or XML) under a binary property named as specified by the user. This allows downstream nodes to handle the exported file data directly.

Dependencies

  • Requires connection to the underlying API or database that stores the "Activity" resource.
  • Needs appropriate API authentication credentials configured in n8n to access the data.
  • No other external dependencies are indicated in the provided code.

Troubleshooting

  • Common issues:

    • Incorrect or missing API credentials will cause authentication failures.
    • Invalid JSON syntax in raw parameter inputs can cause parsing errors.
    • Requesting too many items without pagination may lead to timeouts or rate limits.
    • Using unsupported field names in filters, sorts, or aggregations may result in errors.
  • Error messages:

    • Authentication errors: Verify API key or token configuration.
    • JSON parse errors: Check raw JSON input for syntax correctness.
    • Validation errors on fields: Confirm field names exist in the "Activity" resource schema.
    • Rate limit or timeout errors: Use "Return All" carefully or apply limits and offsets.

Links and References

Discussion