Guides
Longer explanations, with examples you can paste in and run. There are few screens to explain, on purpose: writing a short handler is the easy part now, so the product's job is to get you into the code quickly and then stay out of the way.
What a script has, without importing anything
Every parameter, in both languages
A script is def main(event)
in Python or export default async function main(event)
in TypeScript. Inside it, these are already there:
| Python | TypeScript | What it is for |
|---|---|---|
db["shop"].sql(statement, params) |
db.source("shop").sql(…) |
run SQL on the data source called shop |
db["shop"].get(table, **where) · .all(table) |
.get(table, where) · .all(table) |
one row, or every row |
with db["shop"].transaction(): |
.transaction(async (tx) => …) |
commit several statements together |
secrets["NAME"] |
secrets.NAME |
the project's secrets |
email(to, subject, body) |
email(to, subject, body) |
send an email when the run ends |
download(name, content) |
download(name, content) |
offer a file to download in the browser |
http(url, json=…) |
await http(url, {json}) |
call another service |
to_csv(rows) · to_table(rows) |
toCsv(rows) · toTable(rows) |
rows as CSV, or as a text table |
print(…) |
console.log(…) |
the run's output |
In TypeScript, calls to db
and http
are awaited. Errors are QueryError
from the database and HttpError
when a request gets no answer.
Scripts
One main(event), and a list of what sets it off — you, a button, a clock, or an address another application posts to. A few lines of code and db["shop"].sql() turn what arrives into rows, with no mapping screen in between.
ReadData sources
Point a project at a PostgreSQL, MySQL, MariaDB or SQL Server database you already have: the address, letting this server in, a login of its own, and what it does and does not do to your database.
ReadREST API
Read and write a data source's tables from another application with a key: filters, sorting, cursors, bulk writes, links between rows, ETags, and every error it can answer.
ReadExamples
Whole integrations written out — Stripe, Shopify, QuickBooks, Slack — to copy into a script and change.
ReadConnecting an assistant
Let Claude or ChatGPT write, test and fix your scripts by talking to them. It acts as you, with the role you already have, and the things it must never be able to do have no tool at all.
Read