Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Fields → List operation in this custom n8n node for Directus allows you to retrieve a list of all fields (columns) defined within a specific collection in your Directus instance. This is useful for dynamically discovering the schema of a collection, automating documentation, or building workflows that need to adapt to changes in the data model.

Common scenarios:

  • Generating dynamic forms or UI elements based on collection fields.
  • Validating or mapping data before inserting/updating items in a collection.
  • Auditing or documenting the structure of collections.

Practical example:
Suppose you have a collection called articles and want to fetch all its fields to build a dynamic import workflow or to display available columns to users.


Properties

Name Type Meaning
Collection options The name of the collection whose fields you want to list. Required.
Split Into Items boolean If enabled, outputs each field as a separate item; otherwise, returns an array of fields in a single item.

Output

  • If Split Into Items is false:
    • The output will be a single item with a json property containing an array of field objects, each representing a field in the specified collection.
  • If Split Into Items is true:
    • Each field will be output as a separate item, with the json property containing the field object.

Example output when "Split Into Items" is false:

{
  "json": [
    {
      "field": "id",
      "type": "integer",
      // ...other field properties
    },
    {
      "field": "title",
      "type": "string"
      // ...other field properties
    }
    // ...
  ]
}

Example output when "Split Into Items" is true:

{
  "json": {
    "field": "id",
    "type": "integer"
    // ...other field properties
  }
}
// Next item:
{
  "json": {
    "field": "title",
    "type": "string"
    // ...other field properties
  }
}

Note: The exact structure of each field object depends on your Directus instance's schema.


Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.

Troubleshooting

  • Invalid Collection Name: If the specified collection does not exist, the node will throw an error. Double-check the collection name.
  • Authentication Errors: If credentials are missing or invalid, you'll receive an authentication/authorization error from Directus.
  • Empty Output: If the collection has no fields, the output will be an empty array or no items (depending on "Split Into Items").
  • Error Handling: If an error occurs and "Continue On Fail" is enabled, the output will contain an error property with the error message.

Links and References

Discussion