Xata is a serverless database that combines PostgreSQL, Elasticsearch, and vector search into one platform. It provides a spreadsheet-like UI, full-text search, and AI features without separate services.
Why Xata Matters
Typical stack: PostgreSQL + Elasticsearch + Pinecone + admin panel. Xata replaces all four with one service and one API.
What you get for free:
- PostgreSQL-compatible database
- Built-in full-text search (Elasticsearch under the hood)
- Vector search for AI applications
- Ask AI: natural language queries over your data
- Spreadsheet-like admin UI
- Branching (like git branches for your database)
- Free tier: 15GB data, 75 requests/second
Quick Start
npm install -g @xata.io/cli
xata auth login
xata init --db my-app
TypeScript SDK
import { getXataClient } from "./xata";
const xata = getXataClient();
// Create record
const post = await xata.db.posts.create({
title: "Hello Xata",
content: "My first post",
tags: ["intro", "database"],
published: true,
});
// Query with filters
const posts = await xata.db.posts
.filter({ published: true })
.sort("created_at", "desc")
.getPaginated({ pagination: { size: 20 } });
// Full-text search
const results = await xata.db.posts.search("machine learning", {
fuzziness: 1,
prefix: "phrase",
highlight: { enabled: true },
});
// Vector search (AI)
const similar = await xata.db.posts.vectorSearch("embedding", queryVector, {
size: 5,
filter: { published: true },
});
// Ask AI (natural language query)
const answer = await xata.db.posts.ask("What are the most popular topics?", {
rules: ["Answer based only on the data in the database"],
});
console.log(answer.answer);
Database Branching
# Create branch (like git)
xata branch create staging
# Work on staging branch
xata branch use staging
# Make schema changes, test data
# Then merge back
xata branch merge staging --into main
REST API
# Query records
curl "https://my-workspace.xata.sh/db/my-app:main/tables/posts/query" \
-H "Authorization: Bearer $XATA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filter": {"published": true}, "sort": [{"created_at": "desc"}]}'
# Full-text search
curl "https://my-workspace.xata.sh/db/my-app:main/tables/posts/search" \
-H "Authorization: Bearer $XATA_API_KEY" \
-d '{"query": "machine learning", "fuzziness": 1}'
Links
Building data-powered apps? Check out my developer tools on Apify or email spinov001@gmail.com for custom solutions.
Top comments (0)