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). Specifically, for the "Default" Resource and the "List/Search" Operation, it enables listing or searching records within a specified collection. Users can paginate through results, apply filters, sort data, and expand related fields.

Common scenarios include:

  • Retrieving paginated lists of records from a PocketBase collection.
  • Searching records with specific filter criteria.
  • Sorting records by one or more fields.
  • Expanding relational fields to include linked data.

Practical example: A user wants to fetch the first 30 customer records from their PocketBase database, filtering only those from a certain city, sorted by last name, and including related order details.

Properties

Name Meaning
Parameters Collection of parameters controlling the list/search operation:
- Page The page number of results to retrieve (minimum 1).
- Elements per Page Number of elements to return per page (minimum 1).
- Filter A string representing filter conditions to narrow down the search results.
- Sort A string specifying sorting order of the results.
- Expand A string indicating related fields to expand/include in the results.

Output

The node outputs an array of JSON objects representing the retrieved records from the PocketBase collection. The structure corresponds directly to the collection's schema, including any expanded relational fields if specified.

No binary data output is produced by this operation.

Example output snippet (simplified):

{
  "items": [
    {
      "id": "recordId1",
      "field1": "value1",
      "field2": "value2",
      ...
    },
    {
      "id": "recordId2",
      "field1": "value3",
      "field2": "value4",
      ...
    }
  ],
  "page": 1,
  "perPage": 30,
  "totalItems": 100,
  "totalPages": 4
}

Dependencies

  • Requires a valid PocketBase API endpoint URL.
  • Requires authentication credentials: username and password for a configured user collection.
  • Uses the official PocketBase JavaScript client library.
  • Requires n8n credential setup for the PocketBase API connection (API URL, user collection, username, password).

Troubleshooting

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

  • Something went wrong: followed by JSON error response
    Indicates an error returned by the PocketBase API during the list/search operation. Check the filter, sort, and expand parameter syntax and values. Also ensure the requested page and elements per page are within valid ranges.

  • Empty or no results returned
    Could be due to overly restrictive filters or requesting a page number beyond available pages. Adjust filter criteria or pagination parameters accordingly.

Links and References

Discussion