A collection of trigger.dev task implementations for Tinybird APIs.
npm install @sdairs/tinybird-trigger-tasks
# or
yarn add @sdairs/tinybird-trigger-tasks
# or
pnpm add @sdairs/tinybird-trigger-tasks
The Query task executes a SQL query using the Query API.
The Copy task executes an on-demand Copy job using the Copy API.
You can provide your Tinybird API token either through the environment variable TINYBIRD_TOKEN
or directly in the task payload.
To run a Copy with no params:
import { tinybirdCopyTask } from '@sdairs/tinybird-trigger-tasks';
const copyResult = await tinybirdCopyTask.triggerAndWait({
pipeId: "YOUR_COPY_PIPE_ID",
token: "YOUR_TOKEN" // Optional if TINYBIRD_TOKEN env var is set
});
To run a Copy with params:
const copyWithParamResult = await tinybirdCopyTask.triggerAndWait({
pipeId: "YOUR_COPY_WITH_PARAM_ID",
params: { test_int: "7" },
token: "YOUR_TOKEN" // Optional if TINYBIRD_TOKEN env var is set
});
To run a Query with no params:
import { tinybirdQueryTask } from '@sdairs/tinybird-trigger-tasks';
const queryResult = await tinybirdQueryTask.triggerAndWait({
sql: "SELECT * FROM table",
token: "YOUR_TOKEN" // Optional if TINYBIRD_TOKEN env var is set
});
To run a Query with params:
const paramResult = await tinybirdQueryTask.triggerAndWait({
sql: "% SELECT * FROM my_ds WHERE number == {{Int8(test_int)}}",
params: { test_int: "7" },
token: "YOUR_TOKEN" // Optional if TINYBIRD_TOKEN env var is set
});