Directus icon

Directus

Consume Directus API

Overview

This node interacts with the Directus API to list revision records. It fetches a collection of revisions, optionally applying filters, sorting, pagination, and aggregation functions. The node supports returning all results or limiting the number of returned items. It can also export the fetched data into files in JSON, CSV, or XML formats.

Typical use cases include:

  • Auditing changes made to content or data entries by retrieving their revision history.
  • Generating reports on data modifications over time.
  • Exporting revision data for backup or analysis purposes.

For example, you might use this node to list all revisions of a particular collection item, filter revisions by author or date, and export the results as a CSV file for further processing.

Properties

Name Meaning
Return All Whether to return all revision records or limit the number of results.
Limit Maximum number of revision records to return (applicable if "Return All" is false). Range: 1 to 100.
Split Into Items If enabled, outputs each element of the revisions array as an individual item instead of a single array.
JSON/RAW Parameters Choose whether to specify query parameters via UI fields or directly as raw JSON.
Query Parameters Raw JSON object specifying query parameters for filtering, sorting, pagination, etc. Used only if "JSON/RAW Parameters" is true.
Additional Fields Collection of optional fields to customize the request, including:
- Aggregate Aggregation functions to perform calculations on revision data, such as count, sum, average, min, max, etc., applied on specified fields.
- Binary Property for Export Data Name of the binary property where exported file data will be stored. Defaults to "data".
- Deep (JSON) Nested relational dataset parameters as JSON, allowing deep querying of related data.
- Export Format to export the API response: JSON, CSV, or XML.
- Fields Comma-separated string to control which fields are returned in the response.
- File Name for Export Data Filename (without extension) for the exported data file. Defaults to "export".
- Filter (JSON) JSON object defining conditions to filter the revisions collection.
- Group By Field(s) to group results by, enabling grouped aggregation like "average rating per month".
- Meta Metadata fields to include in the response.
- Offset Number of items to skip when fetching data (for pagination).
- Search Text query to filter revisions containing the given search term in any field.
- Sort CSV string defining sort order of returned items. Prefix field with "-" for descending order, or use "?" for random sorting.

Output

The node outputs JSON data representing the revisions retrieved from the Directus API. The structure corresponds to the API's revision objects, typically including fields such as revision ID, timestamp, user who made the change, and details of the changes.

If "Split Into Items" is enabled, each revision is output as a separate item; otherwise, all revisions are output as a single array.

If an export format is selected (JSON, CSV, or XML), the node also outputs the data as a binary file under the specified binary property name. This allows downstream nodes to handle the exported file (e.g., save it to disk or upload it).

Dependencies

  • Requires a valid Directus API credential with appropriate permissions to access revisions.
  • The node uses the Directus REST API endpoints for revisions.
  • No additional external dependencies beyond the Directus API and n8n environment.

Troubleshooting

  • Authentication errors: Ensure the API credential is correctly configured and has permission to read revisions.
  • Invalid JSON in parameters: When using JSON/RAW parameters, ensure the JSON syntax is correct to avoid parsing errors.
  • Limit exceeded: The API limits the maximum number of items per request (max 100). Use "Return All" to paginate through all results.
  • Export issues: If exporting data, verify that the binary property name and file name are set correctly.
  • Empty results: Check filters, search queries, and other parameters to ensure they match existing revision data.

Common error messages usually come from the Directus API and indicate issues like unauthorized access, invalid parameters, or resource not found. Review the error message details and adjust node parameters accordingly.

Links and References

Discussion