Metabase Custom icon

Metabase Custom

Use the Metabase API

Actions4

Question → Execute Query

AI-generated

Overview

The node provides integration with the Metabase API, specifically allowing users to execute SQL queries against a specified Metabase database. This is useful for retrieving data directly from Metabase questions or running custom queries within an n8n workflow. Typical use cases include automating data retrieval for reporting, triggering workflows based on query results, or saving query cards programmatically.

For the Question resource and Execute Query operation, the node sends a user-defined SQL query to a selected Metabase database and returns the query results.

Properties

Name Meaning
Database ID The numeric identifier of the Metabase database where the query will be executed.
Query The SQL query string to run against the specified database.

Output

The node outputs the full response from the Metabase API call in the json output field. This typically includes the query result data structured as rows and columns matching the SQL query output.

If the query executes successfully, the output JSON contains the data returned by Metabase, which can be used downstream in the workflow for further processing or decision-making.

No binary data output is indicated in the provided code.

Dependencies

  • Requires a valid Metabase API authentication token configured in the node credentials.
  • Needs the base URL of the Metabase instance to send API requests.
  • The node depends on the Metabase API being accessible and the provided database ID existing in the Metabase environment.

Troubleshooting

  • Invalid Database ID: If the database ID does not exist or is incorrect, the API will return an error. Verify the database ID in Metabase.
  • Malformed SQL Query: Syntax errors in the SQL query will cause the API to reject the request. Ensure the query is valid SQL supported by the target database.
  • Authentication Errors: Missing or invalid API credentials will prevent successful API calls. Confirm that the API key/token is correctly set up.
  • Network Issues: Connectivity problems to the Metabase server will cause request failures. Check network access and the correctness of the base URL.
  • API Rate Limits or Permissions: Insufficient permissions or rate limiting on the Metabase side may cause errors. Ensure the API user has rights to execute queries.

Links and References

Discussion