<!-- https://developers.silktide.com/v1/concepts/tables | Concepts -->

# Tables

Many results queries answer with a table: rows of the same shape, such as one row per page with its visitors and page views. Every table takes the same arguments for choosing its columns, its order and its rows, beside the arguments of its own.

## Arguments

| Argument | What it does |
| --- | --- |
| `columns` | The columns to return, comma-separated: `url,pageViews`. Left out, the table returns its default columns. |
| `sort` | The column to sort by, then `:a` for ascending or `:d` for descending: `pageViews:d`. Left out, each table has an order of its own. |
| `search` | Only the rows that match this text. What it searches depends on the table, most often a URL or a title. |
| `page`, `rowsPerPage` | Which page of rows to return, and how many a page holds. See [Pagination](https://developers.silktide.com/v1/concepts/pagination.md). |

Send `columns` as a comma-separated string, in the query string and in a JSON body alike. A table ignores a JSON array.

When you choose `columns`, also send `sort` naming one of them. Some tables fail when the columns you ask for leave out the one they sort by by default.

```bash
curl "https://api.eu.silktide.com/v1/results/analytics/pages?view=all&period=last-30-days&columns=url,pageViews&sort=pageViews:d&rowsPerPage=10" \
  -H "Authorization: silktide token=YOUR_API_KEY"
```

## The answer

A table answers with one page of its rows, and where that page sits among the rest:

```json
{
  "result": {
    "page": 1,
    "minPage": 1,
    "maxPage": 4,
    "numRows": 37,
    "rowsPerPage": 10,
    "rows": [
      { "url": "https://fakewinebarrel.com/", "pageViews": 620 }
    ]
  },
  "selector": "/v1/results/analytics/pages",
  "duration": 0.03
}
```

Each table's page lists the columns its rows can have. A row can also carry fields its page does not list, for Silktide's own screens; ignore them, because they can change without notice.
