# Read a table's rows (/build/read-rows)

Read a table's rows a page at a time, choose which columns come back, and get totals for the whole table or for each group of rows.



A [table](/build/tables) can hold many rows, so a read answers one page, only the columns you name, or totals in place of rows. The examples read a trip budget, a `core.table` item whose one table is named `table`. In the TypeScript examples, `marfa` is a client made as [the TypeScript SDK](/reference/typescript-sdk#create-a-client) shows.

## Read a page of rows [#read-a-page-of-rows]

[List table rows](/reference/api/tables/listTableRows) takes a `filter`, a `sort` and a `limit`:



**CLI**

```bash  
marfa rows list <id> table --filter 'values.category eq "food"' --sort values.day
```

**HTTP**

```http
GET /items/<id>/tables/table/rows?filter=values.category%20eq%20%22food%22&sort=values.day
Authorization: Bearer <key>
```

**TypeScript**

```ts
const { data, error } = await marfa.GET("/items/{id}/tables/{table}/rows", {
  params: {
    path: { id, table: "table" },
    query: { filter: 'values.category eq "food"', sort: "values.day" },
  },
});
```

* **A page holds 100 rows, or up to 1,000 with `limit`.** Send the answer's `next_cursor` back as `cursor` for the next page, until it is `null`.
* **A `filter` uses the [item filter grammar](/build/list-filter-search#filter-by-properties).** A column is `values.<column>`, and `id` and `updated_at` are the row's own.
* **`sort` takes `id`, `updated_at` or `values.<column>`,** with `direction`. Without it, rows come in the table's own `order`, or by `id` when the table names none. An `item` column sorts as no value, so its pages come in `id` order.

## Choose the columns [#choose-the-columns]

A row can hold up to 64 KiB of values. **Name `columns` and each row carries only those,** so a list that shows two columns doesn't fetch the rest:

```bash
marfa rows list <id> table --filter 'values.category eq "food"' --columns item,amount
```

Output:

```text
id                                    updated                   values
01a2394f-0f72-748b-ad84-2b309109a0c4  2026-12-03T00:36:06.869Z  {"item":"Dinner","amount":48.5}
01a2394f-0f72-748b-ad84-2b31f229606a  2026-12-03T00:30:12.335Z  {"item":"Lunch","amount":21}
```

Over HTTP it is the query parameter `columns=item,amount`, on a page of rows and on [one row](/reference/api/tables/getTableRow). A row's `id` and `updated_at` always come back. A `filter` or a `sort` may name a column you left out, and a cursor works with or without `columns`. A name the table doesn't declare, an empty list or more than 64 names is refused `400 validation_error` naming `columns`.

## Total the rows [#total-the-rows]

[Get table totals](/reference/api/tables/getTableTotals) answers how many rows a `filter` selects, and the total of each column that [adds up](/catalog/field-kinds#columns):

```bash
marfa rows totals <id> table --filter 'values.day gte "2026-05-01" AND values.day lt "2026-06-01"'
```

Output:

```text
row_count          3
totals.amount.sum  570.9
```

A total counts only values the column's type takes. A value that a forced type change left behind, such as a fraction in an `integer` column, is left out.

## Total by group [#total-by-group]

[Get table totals by group](/reference/api/tables/getTableGroups) answers the same totals for each group of rows that share a column's value. This totals the budget by month:



**CLI**

```bash  
marfa rows groups <id> table --group values.day:month
```

**HTTP**

```http
POST /items/<id>/tables/table/groups
Authorization: Bearer <key>
Content-Type: application/json

{ "group": [{ "by": "values.day", "bucket": "month" }] }
```

**TypeScript**

```ts
const { data, error } = await marfa.POST("/items/{id}/tables/{table}/groups", {
  params: { path: { id, table: "table" } },
  body: { group: [{ by: "values.day", bucket: "month" }] },
});
```

```json title="Response"
{
  "row_count": 4,
  "totals": { "amount": { "sum": 591.9 } },
  "groups": [
    { "key": "2026-05-01", "row_count": 3, "totals": { "amount": { "sum": 570.9 } } },
    { "key": "2026-06-01", "row_count": 1, "totals": { "amount": { "sum": 21 } } }
  ]
}
```

* **`group` holds one grouping or two.** With two, each group carries the second grouping's groups in its own `groups`, with exact subtotals.
* **A `bucket` groups a `date` or `datetime` column** by `day`, `week`, `month` or `year`. The key is the first date of the span, and a week starts on Monday.
* **`time_zone`, an IANA name such as `Europe/Lisbon`, decides which date a `datetime` falls on for a `bucket`.** Without it the server reads UTC.
* **Groups come in ascending order of `key`, and the `null` group last.** It holds the rows with no value in the column, or with a value the column's type doesn't take.
* **An answer is never cut.** A `filter` that selects more than 100,000 rows is refused `400 validation_error` naming `filter`, and more than 1,000 groups naming `group`.

## Text in a column changed to item [#text-in-a-column-changed-to-item]

A column that held text can become `item`, for example by a type replacement forced with `force=true` over HTTP or a change to a `core.table` item's `columns`. At first, a key that can't read every type finds the column in the row's `withheld`, not in `values`. Its filters, totals, events and archive exports leave the text out, and its writes that name the column in such a row are refused `403 forbidden`.

The change brings forward the `table-row-cleanup` [job](/run/check-health#see-what-the-jobs-did), which records each value that is the ID of an item Marfa holds. A key then sees those whose item it may read. **Other text stays hidden from such keys for good.** An [undo](/build/write-rows#take-a-batch-back) that puts such an ID back records it at once; after a restore, the job does.

A key that reads every type reads every value, and a number is never hidden. This applies from the next Marfa release after v0.0.122; v0.0.122 shows the text to any key that reads the row ([`tables/rows-item-unwritten`](https://github.com/withmarfa/marfa/blob/main/conformance/spec/tables.md#tablesrows-item-unwritten)).

## Read rows in a working copy [#read-rows-in-a-working-copy]

`marfa device rows list`, `get`, `totals` and `groups` take the same options. A [working copy](/build/write-in-a-working-copy#keep-it-current) answers from a table it holds whole and asks the server otherwise, and `held` in the answer says which. Where a read names no time zone, a device groups by its own.

From the next Marfa release after v0.0.122, `--all` makes `marfa device rows list` read every page, with `--limit` as the page size; in v0.0.122, the command prints only the first page.

The rules are in the contract's [tables](https://github.com/withmarfa/marfa/blob/main/conformance/spec/tables.md#reading-rows) chapter.
