PocketBase icon

PocketBase

Consume PocketBase API

Overview

This node integrates with the PocketBase API, allowing users to interact with PocketBase collections (referred to as Resources). It supports common CRUD operations such as listing/searching elements, viewing a single element, creating new elements, and updating existing ones within a specified collection.

A typical use case is automating data workflows where PocketBase serves as a backend database. For example, you can list records with filters and pagination, retrieve detailed information about a specific record by its ID, or update/create records programmatically based on other workflow data.

The "View" operation specifically retrieves a single element from a given collection by its unique Element ID, returning all its fields.

Properties

Name Meaning
Element ID The unique identifier of the element to view or update in the selected collection.
Parameters A collection of optional parameters for listing/searching:
- Page The page number to retrieve (minimum 1).
- Elements per Page Number of elements to return per page (minimum 1).
- Filter A filter string to narrow down results (used in search/list operations).
- Sort Sorting criteria for the results (used in search/list operations).
- Expand Fields to expand in the response (used in search/list operations).

Note: For the "View" operation, only the "Element ID" property is relevant.

Output

The output is a JSON array where each item corresponds to an element retrieved from PocketBase.

For the "View" operation, the output JSON object contains all fields of the requested element identified by the provided Element ID. The structure matches the PocketBase collection schema, including any expanded fields if specified.

No binary data output is produced by this node.

Example output JSON for "View":

{
  "id": "element-id",
  "created": "2023-01-01T00:00:00Z",
  "updated": "2023-01-02T00:00:00Z",
  "field1": "value1",
  "field2": "value2"
}

Dependencies

  • Requires a valid PocketBase API endpoint URL.
  • Requires authentication credentials: username and password for a user in PocketBase.
  • Uses the official PocketBase JavaScript client library.
  • Requires n8n credential configuration to store the PocketBase API URL and user credentials securely.

Troubleshooting

  • Authentication failed!
    This error occurs if the provided credentials are invalid or the authentication request fails. Verify that the API URL, username, and password are correct and that the user has access to the specified collection.

  • Element not found or invalid Element ID
    If the Element ID does not exist in the collection, the node will throw an error. Ensure the Element ID is correct and exists in the target collection.

  • Invalid parameters or missing required fields
    When creating or updating elements, ensure all required fields are provided and correctly formatted.

  • Network or API errors
    Check network connectivity and that the PocketBase server is reachable.

If continueOnFail is enabled, the node will continue processing subsequent items even if one fails, attaching error details to the output.

Links and References

Discussion