Fetch data
Fetches rows from a table or view using structured conditions, optional pagination, sort instructions, and optional post-processing (`group_by`, `time_granularity`, aggregation options). Notes: - Route selection supports `X-Athena-Client` or direct PostgreSQL URI headers (`x-pg-uri` preferred). - Direct URI auth bypass is allowed when URI credentials include both username and password. - Direct URI requests always execute inline (deferred gateway queue is skipped). - Optional `schema_name` targets a non-default schema. When provided, `table_name` must not already be schema-qualified. - PostgreSQL-backed fetch execution accepts canonical nested `select` payloads and compatibility `select` strings. - Schema-qualified base tables such as `public.chat_subscriptions` are supported. - Relation-side schema qualification such as `users:athena.users(id,username,image)` is supported. - Legacy `columns` + `conditions` payloads remain supported and are still the right shape for wildcard/simple fetches and non-PostgreSQL gateway fetch backends. - Structured fetch auth checks apply to every referenced table in the nested tree when API-key enforcement is enabled. - Relation joins resolve from foreign-key metadata first; ambiguous edges should provide `foreign_key`. - Unsupported in this release: top-level AST request bodies (`operation` / `from` / `fields`), relation `on` shapes, and schema-qualified relation selectors combined with `via`. - `X-Strip-Nulls` can be used to remove null-valued fields from response payloads. - Cache behavior may include `X-Athena-Cached`, `X-Athena-Cache-Outcome`, and `X-Athena-Cache-Source` headers.
Header Parameters
Registered Athena client name. Optional when direct PostgreSQL URI headers are provided.
Preferred direct PostgreSQL URI (postgres://... or jdbc:postgresql://...).
Compatibility direct PostgreSQL URI header.
Compatibility direct PostgreSQL URI header.
optional API key mirror of the apikey header
Required when X-Athena-Client is custom_supabase
uriRequired when X-Athena-Client is custom_supabase
Request Body
application/json
Root table name for legacy and structured fetch bodies.
Optional schema override (defaults to public search_path behavior).
Structured select projection. Use nested objects for the canonical Athena contract or a PostgREST/Supabase-style string for compatibility.
Structured filters using eq, neq, gt, lt, or in operators.
Explicit structured filter array used by compatibility rewrites and advanced callers.
Structured ordering for canonical nested select payloads.
Legacy projection contract. Keep using this for wildcard or non-PostgreSQL fetch bodies.
Column name to group results by
Time granularity for grouping timestamp data
"day" | "hour" | "minute"Column to aggregate (required when using aggregation_strategy)
Aggregation strategy to apply (requires aggregation_column)
"cumulative_sum"Whether to deduplicate during aggregation
Optional sort (camelCase). Use sort_by for snake_case.
Optional sort (snake_case). Same shape as sortBy.
Response Body
application/json
application/json
curl -X POST "https://athena-cluster.com/gateway/fetch" \ -H "Content-Type: application/json" \ -d '{ "table_name": "public.chat_subscriptions", "select": "users:athena.users(id,username,image),user_id", "where_filters": [ { "column": "user_id", "operator": "eq", "value": "ef7a4c74-cc35-4d32-945a-a5271279ecdb", "column_cast": "text" } ], "orderBy": [ { "column": "user_id", "direction": "desc" } ], "limit": 1 }'{
"status": "success",
"message": "Fetched 1 rows",
"data": [
{
"user_id": "ef7a4c74-cc35-4d32-945a-a5271279ecdb",
"users": {
"id": "ef7a4c74-cc35-4d32-945a-a5271279ecdb",
"username": "floris",
"image": "https://cdn.example.com/avatar.png"
}
}
],
"cache_key": "chat_subscriptions:compatibility:true:7c9b53f4f1f0b902"
}{
"status": "error",
"message": "Invalid structured select request",
"error": "table 'athena.user' was not found for structured gateway fetch",
"code": "VALIDATION_FAILED",
"data": {
"operation": "fetch"
}
}Delete data DELETE
Deletes rows from the target table, usually by primary/resource identifier fields in the request body. Route authorization and client routing follow the same model as other gateway mutations (`X-Athena-Client` or direct PostgreSQL URI header). Direct URI requests execute inline (deferred queue bypassed).
Insert data PUT
Inserts one row (or server-normalized payload) into the target table selected by `X-Athena-Client` or a direct PostgreSQL URI header (`x-pg-uri` preferred). The optional `X-Athena-Insert-Window` header can enable request-scoped batching for Postgres-backed inserts. Conflict responses (409) are typically raised for unique/constraint violations. Direct URI requests are executed inline (gateway deferred queue bypassed).