APIs and SDKs
Common workflows
End-to-end examples for the things most applications need on day one.
Sign up, verify, and sign in
// 1. create the user
await rb.from("users").create({
email: "[email protected]",
password: "a-strong-password",
passwordConfirm: "a-strong-password",
name: "Ada",
});
// 2. send the verification email
await rb.auth("users").requestVerification("[email protected]");
// 3. sign in
await rb.auth("users").signInWithPassword("[email protected]", "a-strong-password");A paginated, searchable list
async function searchPosts(term: string, page = 1) {
return rb.from("posts").list({
page,
perPage: 20,
filter: 'published = true && title ~ "' + term + '"',
sort: "-created",
expand: "author",
});
}Escape or validate user input before building a filter string, exactly as you would for any query language.
Create a parent and its children together
const batch = rb.batch();
batch.from("orders").create({ customer: customerId, status: "new" });
batch.from("order_items").create({ sku: "A-1", quantity: 2 });
batch.from("order_items").create({ sku: "B-7", quantity: 1 });
const results = await batch.send();Live dashboard tile
const initial = await rb.from("orders").list({ perPage: 10, sort: "-created" });
render(initial.items);
await rb.from("orders").subscribe("*", async () => {
const fresh = await rb.from("orders").list({ perPage: 10, sort: "-created" });
render(fresh.items);
});Server-to-server access with an API key
curl $PROJECT_URL/api/v1/collections/orders/records \
-H "Authorization: $RUSTABASE_API_KEY" \
--data-urlencode 'filter=status = "new"' -GKeep API keys in server environment variables or Project secrets. A key in browser code is a public key.
Found something wrong on this page?
Fix it yourself. The link below opens this file in GitHub's editor and forks the repository for you if you need one, and your change becomes a pull request without leaving the browser.