Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Items → Get

AI-generated

Overview

The Directus (DrWade) n8n node for the Items resource with the Get operation retrieves a single item from a specified collection in your Directus instance by its unique ID. This is useful when you need to fetch detailed information about a specific record, such as displaying user profiles, fetching article details, or retrieving any custom data stored in Directus collections.

Practical examples:

  • Fetching a blog post by its ID from an "articles" collection.
  • Retrieving a user's profile details using their unique identifier.
  • Getting product information from an e-commerce catalog.

Properties

Name Type Meaning
ID String Unique ID of the item to retrieve from the collection. Required.
Collection Options The name of the parent collection from which to fetch the item. Required.
Return All Boolean Not used in this operation (relevant for list operations).
Limit Number Not used in this operation (relevant for list operations).
Additional Fields Collection Optional advanced query parameters and export options (see below for subfields).

Additional Fields sub-options relevant for Get:

Name Type Meaning
Aggregate Fixed Collection Not applicable for single get.
Binary Property for Export Data String If exporting, the name of the binary property to store file data.
Deep (JSON) JSON Allows setting nested relational query parameters.
Export Options If set, saves the API response to a file (json, csv, xml).
Fields String Controls which fields are returned in the object.
File Name for Export Data String File name for exported data (without extension).
Filter (JSON) JSON Not typically used for single get.
Group By String Not applicable for single get.
Meta String Specifies what metadata to return in the response.
Offset Number Not applicable for single get.
Search String Not applicable for single get.
Sort String Not applicable for single get.

Output

  • The output will be a single item from the specified collection, returned as a JSON object under the json field.
  • The structure of the output depends on the fields present in the collection and any field selection applied via the "Fields" property.
  • If the "Export" option is used, the response can also include a binary field containing the exported file (in JSON, CSV, or XML format).

Example output:

{
  "json": {
    "id": "15",
    "title": "Sample Article",
    "author": "John Doe",
    "created_at": "2024-06-01T12:00:00Z"
    // ...other fields depending on the collection schema
  }
}

If exporting:

{
  "json": { /* same as above */ },
  "binary": {
    "data": { /* binary file data */ }
  }
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n (typically includes API URL and authentication token).

Troubleshooting

Common issues:

  • Invalid ID or Collection: If the provided ID does not exist in the specified collection, the node will throw an error or return an empty result.
  • Missing Credentials: If the Directus API credentials are not configured, the node will fail to connect.
  • Insufficient Permissions: The API user must have permission to read items from the target collection.
  • Field Selection Errors: Specifying non-existent fields in the "Fields" property may cause errors or missing data in the output.

Error messages and resolutions:

  • "Collection not found": Check that the collection name is correct and exists in Directus.
  • "Item not found": Verify the ID is valid for the selected collection.
  • "Unauthorized": Ensure your API credentials are correct and have sufficient permissions.

Links and References


Discussion