# Query Records

`GET /data/{collection}` · Core · Data, Queries & Vectors

Retrieves records from a named user-collection using cursor-based pagination and the full query-builder vocabulary:

- column filters (Supabase-style `?col=op.value`)
- column selection
- multi-column ordering
- `.single()` assertion
- range access
- OR groups
- aggregates
- embedded joins
- full-text search (`?textSearch=col:query`)
- vector/semantic search (`?vectorSearch`)

All four query modes route through the `_query` credential and are subject to compiled RLS policies; filters compose as additional AND constraints that cannot widen visibility beyond the caller's auth context.

Returns `K9O_COLLECTION_NOT_FOUND` (404) if the collection does not exist, and `K9O_MULTIPLE_ROWS_RETURNED` (409) when `.single()` matches more than one row.

Filters are bounded:

- a `match`, `like` or `ilike` pattern may be at most 256 characters;
- a `jsonPath` may be at most 512 characters;
- an `in` or `notIn` list may hold at most 1,000 items.

Past a cap the read answers `K9O_INVALID_FILTER` (400) with `context.reason` `operand_too_long` or `too_many_items` and `context.max`.

The read runs under a time limit (10 seconds by default). A read that runs past it answers `K9O_QUERY_TIMEOUT` (504) with `context.timeoutSeconds`, and nothing is returned.

On a protected column, `eq` and `in` are allowed only when the read returns that column as plaintext. On a searchable column that needs a reveal purpose, the same read must reveal it (`reveal=<column>&revealPurpose=...`), and it is audited as a reveal even when no row matches. Without that reveal the read answers `K9O_ENCRYPTED_COLUMN_OPERATION_UNSUPPORTED` (400) with `context.reason: "reveal_required"`. An aggregate carries no reveal, so it refuses the same way.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `collection` | path | yes | The collection's name. Example: `"products"`. |
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Responses

- **200**: Success

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | A page of records; a single record with `single=true` (an error when no record or more than one record matches); or the aggregate values with `aggregate`. |
| _one of_ | | |  |
| _or_ | | |  |
| _or_ | | |  |
| `meta` | object | yes | Request metadata (cost, timing, request and trace ids), plus the pagination cursor on a list answer. |
| `meta.cursor` | object | no | Pagination. Present on a list answer; absent with `single` or `aggregate`. |
| `meta.cursor.next` | object | yes | Opaque cursor for the next page; pass it back as `cursor`. Null on the last page, and always null with `range`. |
| _one of_ | | |  |
| _or_ | | |  |
| `meta.cursor.totalCount` | object | no | The filtered row count when `count` is `exact` or `estimated` (from the planner's statistics); null when `count` is `none` (the default). Absent with `deleted=true`. |
| _one of_ | | |  |
| _or_ | | |  |
| `meta.cursor.countMethod` | enum ("none", "exact", "estimated") | no | The `count` mode the read ran with. Absent with `deleted=true`. |
| `meta.warnings` | array of object | no | Present only when a warning applies. |
| `meta.warnings.[]code` | string | yes | A warning code. This read adds `K9O_ORG_CLAIM_UNBOUND` (the token has no org claim, so org-scoped row policies may hide every row) and `OFFSET_PAGINATION_INEFFICIENT` (a `range` starting past row 1000). |
| `meta.warnings.[]message` | string | yes | A readable explanation. |


## Errors

| HTTP | Code | When |
|---|---|---|
| 401 | `K9O_SESSION_EXPIRED` | Your session has expired; sign in again to query data. |
| 401 | `K9O_INVALID_CREDENTIALS` | The credentials provided are not valid; the data query was rejected. |
| 403 | `K9O_ACCESS_DENIED` | Your role does not permit reading from this collection. |
| 404 | `K9O_COLLECTION_NOT_FOUND` | The requested collection does not exist in this project. |
| 403 | `K9O_FIELD_REVEAL_DENIED` | You requested reveal of a protected field without supplying a purpose or without reveal authority (an administrator role or a fields.<column>.reveal grant). |
| 400 | `K9O_INVALID_FIELD_VALUE` | A filter, select or order expression is invalid, or the vectorSearch column does not exist on the collection, is not a vector column (reason not_a_vector_column), or holds a different dimension than the query vector (reason dimension_mismatch). |
| 400 | `K9O_INVALID_FILTER` | A filter operand is past its cap: a `match`, `like` or `ilike` pattern over 256 characters or a `jsonPath` over 512 (`context.reason: "operand_too_long"`), or an `in` / `notIn` list over 1,000 items (`too_many_items`). `context.column`, `context.op` and `context.max` say which. |
| 400 | `K9O_ENCRYPTED_COLUMN_OPERATION_UNSUPPORTED` | The operation is not supported on a protected column: only `eq` and `in` on a searchable one, and on one that needs a reveal purpose only in a read that reveals it (`context.reason: "reveal_required"`). |
| 504 | `K9O_QUERY_TIMEOUT` | The read ran past its time limit and returned nothing. `context.timeoutSeconds` gives the limit; narrow the filter or simplify a pattern. |

## Code samples

### cURL

```bash
curl -X GET 'https://<org>.api-<region>.k9o.io/@storefront/data/products' \
  -H 'Authorization: Bearer $K9O_TOKEN'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/data/products', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${process.env.K9O_TOKEN}`
  },
});
const { data, meta } = await res.json();
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.from('products').select()
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.from_("products").select()
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.From("products").Select()
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.from("products").select().await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.from("products").select()
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.From("products").SelectAsync()
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.from("products").select()
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->from('products')->select()
```

### K9o

```swift
// let k9o = try K9o.createClient(orgSlug: "playground", projectSlug: "storefront", apiKey: "k9o_…")
let result = try await k9o.from("products").select()
```

### core-kotlin

```kotlin
// val k9o = createClient { orgSlug = "playground"; projectSlug = "storefront"; apiKey = "k9o_…" }
val result = k9o.from("products").select()
```

### k9o (Flutter)

```dart
// final k9o = K9o.createClient(orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…');
final result = await k9o.from('products').select()
```

### @k9o/react-native

```javascript
// const k9o = createClient({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })  // RN, secure storage
const { data } = await k9o.from('products').select()
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/query-records
