Xata icon

Xata

Consume Xata API

Overview

The Xata node for n8n allows you to interact with the Xata database service. Specifically, when using the List operation under the Default resource, this node retrieves records from a specified table in your Xata workspace. It supports filtering, sorting, column selection, pagination, and limiting the number of results.

Common scenarios:

  • Fetching all or a subset of records from a Xata table for further processing in an n8n workflow.
  • Filtering and sorting data before passing it to other nodes (e.g., sending filtered customer lists to email campaigns).
  • Integrating Xata data into automation pipelines, such as syncing with other databases or services.

Practical examples:

  • Retrieve all user records where "status" is "active".
  • Get the latest 10 orders sorted by creation date.
  • Fetch only specific columns (e.g., "email", "name") from a contacts table.

Properties

Name Type Meaning
Workspace Slug string The unique slug identifier for your Xata workspace. Required to target the correct workspace.
Database Location options The region where your Xata database is hosted. Options: us-east-1, us-west-2, eu-west-1.
Database Name string The name of the database within your workspace to access.
Branch Name string The branch of the database to query (useful for environments like dev/staging/prod).
Table Name string The name of the table from which to list records.
Return All boolean Whether to return all matching records (true) or limit the number of results (false).
Size number If "Return All" is false: Maximum number of results to return (min: 1, max: 200).
Additional Options collection Advanced options for customizing the query:
- Columns (string[]): Only include these columns in the result.
- Filter (JSON) as String: JSON filter for records.
- Sort (JSON) as String: JSON sort order.
- Offset (number): Number of records to skip (if "Return All" is false).
- Size (number): Results per page (if "Return All" is true; min: 1, max: 200).

Output

  • The output is a JSON array of records retrieved from the specified Xata table.
  • Each item in the array represents a record, with keys corresponding to the selected columns (or all columns if none are specified).
  • If an error occurs and "Continue On Fail" is enabled, the output may contain objects with an error field describing the issue.

Example output:

[
  {
    "id": "rec_123",
    "name": "Alice",
    "email": "alice@example.com"
  },
  {
    "id": "rec_456",
    "name": "Bob",
    "email": "bob@example.com"
  }
]

Dependencies

  • External Service: Requires access to the Xata API.
  • API Key: You must provide valid Xata API credentials via the xataApi credential in n8n.
  • n8n Configuration: No special environment variables required beyond standard credential setup.

Troubleshooting

Common issues:

  • Missing or invalid credentials:
    Error message: No credentials provided for Xata Api
    Resolution: Ensure that the xataApi credential is configured correctly in n8n.

  • Incorrect workspace/database/branch/table names:
    Error message: May receive a 404 or similar error from Xata.
    Resolution: Double-check the spelling and existence of the workspace, database, branch, and table.

  • Invalid filter/sort JSON:
    Error message: Xata API may return parsing errors if the filter or sort strings are not valid JSON.
    Resolution: Ensure that any filter or sort input is properly formatted as a JSON string.

  • Exceeding size limits:
    Error message: May receive validation errors if "Size" is set outside allowed bounds (1–200).
    Resolution: Adjust the "Size" property to be within the permitted range.


Links and References

Discussion