Read rows from tables and views with GET requests or the SDK.
#Select all columns
const { data, error } = await stitchdb.from('todos').select('*')curl 'https://<project-ref>.p.stitchdb.com/rest/v1/todos?select=*' -H "apikey: <anon-key>"#Select some columns
const { data } = await stitchdb.from('todos').select('id, task')curl 'https://<project-ref>.p.stitchdb.com/rest/v1/todos?select=id,task' -H "apikey: <anon-key>"#Related rows
Fetch related rows through foreign keys by naming the related table in select. Rename with alias:column, and add !inner to keep only rows that have a match:
const { data } = await stitchdb.from('todos').select('id, task, owner:profiles(username)')
const { data: mine } = await stitchdb.from('todos').select('id, profiles!inner(username)').eq('profiles.username', 'ada')curl 'https://<project-ref>.p.stitchdb.com/rest/v1/todos?select=id,task,owner:profiles(username)' -H "apikey: <anon-key>"#One row
JavaScript
const { data } = await stitchdb.from('todos').select('*').eq('id', 1).single() // error unless exactly one row
const { data: maybe } = await stitchdb.from('todos').select('*').eq('id', 1).maybeSingle() // null when none#Count rows
const { count } = await stitchdb.from('todos').select('*', { count: 'exact', head: true })curl -I 'https://<project-ref>.p.stitchdb.com/rest/v1/todos?select=*' -H "apikey: <anon-key>" -H "Prefer: count=exact"
# Content-Range: 0-24/1250count: 'planned' or 'estimated' are faster on large tables.
#Other formats
JavaScript
const { data: csv } = await stitchdb.from('todos').select('*').csv()
const { data: plan } = await stitchdb.from('todos').select('*').explain()Each response returns at most your plan's rows per API request; page through larger results (see Filtering and pagination).