Your database should be easy to use, not a source of frustration. Xata easily integrates into your developer workflow, providing the best data experience for Github, Vercel and Netlify based deployments.
See how Xata works
// Typings and client automatically up to date import { getXataClient, Posts } from '../xata'; const xata = getXataClient(); // Fetching the posts is as easy as: const posts: Posts[] = await xata.db.Posts.getMany();
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Filter on author Monica Sarbu const posts = await xata.db.Posts .filter("author.name", "Monica Sarbu") .getMany();
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Sort by date descending and paginate your content const records = await xata.db.Posts .filter("author.name", "Monica Sarbu") .sort("date", "desc") .getPaginated();
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Insert a new record to the posts table const record = await xata.db.Posts.create({ title: 'My new post', labels: ['engineering', 'marketing'], slug: 'my-new-post', content: 'This is pretty neat!', author: 'author_id', date: new Date('2023-04-26T00:00:00Z') });
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Update an existing post const record = await xata.db.Posts.update('my_post_id', { title: 'My updated post title' });
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Delete an existing post const record = await xata.db.Posts.delete("my_post_id");
Create and populate a database in seconds. Based on PostgreSQL, adding rich data types, a schema editor and a table editor that feels like a spreadsheet — Xata makes databases simple and accessible to the whole team.
Learn More// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Search authors and posts tables for next.js const records = await xata.search.all("next.js", { tables: [{ table: "authors" }, { table: "posts" }] prefix: "phrase", });
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Search only the content column in the posts table for next.js const records = await xata.search.all("next.js", { tables: [{ table: "posts", target: [{ column: "content" }] }], prefix: "phrase", });
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Boost the weight of content and title columns to provide a higher relevancy score const records = await xata.search.all("next.js", { tables: [ { table: "posts", target: [ { column: "content", weight: 5 }, { column: "title", weight: 5 }, ], }, ], prefix: "phrase", });
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Add typo tolerance with fuzziness of 2 const records = await xata.search.all("next.js", { tables: [ { table: "posts", target: [ { column: "content", weight: 5 }, { column: "title", weight: 5 }, ], }, ], fuzziness: 2, prefix: "phrase", });
Get a lighting-fast, free-text search engine with analytics for performant search at scale, automatically. Leveraging the power of Elasticsearch, you can boost your results and add typo-tolerant fuzzy search in just a few clicks.
Learn More$ xata branches list Name Created at Git branch change_column Apr 20, 2023, 8:20 PM - feature1 Apr 17, 2023, 11:58 PM - feature2 Apr 20, 2023, 7:41 PM - main Apr 17, 2023, 11:50 PM main (Current)
# Create a branch in code or the UI xata branch create my-changes # Made changes in the UI? Pull them down xata pull my-changes # Made changes in the code? Push them up xata push my-changes
Branches are a first class citizen in the Xata API. They are created instantly and are the key to the Xata developer workflow, because they enable deployment previews, testing schema changes, and zero-downtime migrations. You can also easily copy the data between branches.
Learn More// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Table and column names are auto-complete by IntelliSense const posts = await xata.db.posts.filter( { "author.name", "Monica Sarbu", "status": "published" } ).getMany();
from xata.client import XataClient client = XataClient(api_key="REDACTED_API_KEY", db_name="my_db", branch_name="feature-042") # Bulk insert multiple records avengers = [ {"name": "Peter Parker", "job": "Spiderman"}, {"name": "Bruce Banner", "job": "Hulk"}, {"name": "Steve Rodgers Parker", "job": "Captain America"}, {"name": "Tony Stark", "job": "Iron Man"}, ] resp = client.records().bulkInsertTableRecords("Avengers", {"records": avengers}) assert resp.status_code == 200
curl --request POST \ --url https://demo-uni3q8.us-east-1.xata.sh/db/test:main/tables/Posts/query \ --header 'Authorization: Bearer xau_<redacted>' \ --header 'Content-Type: application/json' \ --data '{ "filter": { "slug": {"$contains": "south"} }, "sort": { "createdAt": "desc" } }'
You get end-to-end type-saftey out of the box and you’ll be amazed by how well IntelliSense auto-complete works with our TypeScript SDK. But Xata is not only for TypeScript: we also have a Javascript SDK, a Python client library, and our REST API is easy to use from any programming language.
Learn More// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Run multiple pre-defined transactions const result = await xata.transactions.run([ { insert: { table: 'titles', record: { originalTitle: 'A new film' } } }, { insert: { table: 'titles', record: { id: 'new-0', originalTitle: 'The squeel' }, createOnly: true } }, { update: { table: 'titles', id: 'new-0', fields: { originalTitle: 'The sequel' }, ifVersion: 0 } }, { update: { table: 'titles', id: 'new-1', fields: { originalTitle: 'The third' }, upsert: true } }, { get: { table: "titles", id: "new-0", columns: ['id', 'originalTitle']}}, { delete: { table: 'titles', id: 'new-0' } } ]);
// Typings and client automatically up to date import { getXataClient, Posts } from '../xata'; const xata = getXataClient(); // atomically increment a counter const user = await xata.db.Users .update("myid", { counter: { $increment: 1 } }); // atomically subtract 42 from a counter const user = await xata.db.Users .update("myid", { counter: { $decrement: 42 } });
Xata has ACID transactions, referential integrity, constraints, and atomic updates to help you keep the data consistent. Transactions allow you to execute multiple operations atomically and in a single network round-trip to the database which is often the key to reduced latency.
Learn More// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // get data for a multi-line chart, where each line represents a movie genre // X axis - date, bucketed by calendar year // Y axis - average rating const results = await xata.db.titles.aggregate({ "movieGenres": { topValues: { column: "genre", size: 50 aggs: { "byReleaseDate": { dateHistogram: { column: "releaseDate", calendarInterval: "year", }, aggs: { "avgRating": { average: { column: "rating" } } } } } } }, })
// Typings and client automatically up to date import { getXataClient, Posts } from '../xata'; const xata = getXataClient(); // summaries are computed on the transactional store and are // strongly consistent const records = await xata.db.titles.summarize({ summaries: { // count all rows "all_sales": {"count": "*"}, // count all rows where `store_id` is not null "all_sales_from_store": {"count": "store_id"}, // sum the `profit` column "total_profit": {"sum": "profit"}, // average the `shipping.time_days` column "average_shipping_time": {"average": "shipping.time_days"}, // count the total rows where `has_arrived` is not null "total_has_arrived": {"count": "has_arrived"}, // retrieve the smallest value in the `package_volume` column "smallest_package": {"min": "package_volume"} // retrieve the largest value in the `sale_price` column "largest_sale_price": {"max": "sale_price"} } })
Xata makes it easy to group, summarize, and aggregate your records. The aggregations API uses a column-oriented store to enable super-fast and scalable analytics on your data. You can create date histograms, numeric histograms, top values visualizations, or combine them into complex visualizations.
Learn More// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Use the ask function to query ChatGPT with your data const result = await xata.db.Tutorial.ask("How do a retrieve a single record?", { rules: [ "Do not answer questions about pricing or the free tier. Respond that Xata has several options available, please check https://xata.io/pricing for more information.", "When you give an example, this example must exist exactly in the context given.", ], searchType: "keyword", search: { boosters: [ { valueBooster: { column: "section", value: "guide", factor: 18 } } ] } })
// Typings and client automatically up to date import { getXataClient } from "./xata"; const xata = getXataClient(); // Find nearest neighbors of the given vector embedding const results = await xata.db.docs.vectorSearch( "embeddings", [0.1, 0.2, 0.3], { size: 5 } );
Build AI-enabled applications with ChatGPT embedded in your database. Xata’s OpenAI integration enables human-like conversations to answer questions in your website, app or knowledge base. Xata also has a rich type for storing embeddings allowing you to perform vector similarity search without a dedicated vector database.
Learn MoreBranch your database like your code. Run xata branch
from our CLI then xata pull
and xata push
to start collaborating with your team.
Hey team. I'm making a feature branch so we can colloborate.
# Create a branch in code or the UI
xata branch create my-changes
# Made changes in the UI? Pull them down
xata pull my-changes
# Made changes in the code? Push them up
xata push my-changes
xata pull
CLIupdated TS Types in src/xata.ts
xata pull
CLIcreated new migration files in .xata/migrations
Create a PR like normal in GitHub. Xata keeps track of your schema changes in the background and will create a comment with your schema and status in the PR.
I made some changes to the Xata schema in the UI. Time to run xata pull my-changes
to get back Types! Now I'll commit the generated migration files into a PR along with my app code.
Alexis
committedadd desc column
into my-changes
just now"addColumn": {
"column": {
"name": "description",
"type": "string"
},
"table": "Posts"
}
Xata
botnoticed a migration on GitHub. Creating a preview branch for this PR.Vercel and Netlify integrations generate a preview branch with your PR and deployment preview, eliminating the need for separate dev and staging environments
Xata
botcommented 3 minutes ago on GitHub
Preview branches created for your PR. Learn more about Xata for GitHub.
Database | State | Preview |
---|---|---|
preview-my-changes | ✅ Ready | View on Xata |
The pull request creates a cloned Xata database with data. Feel free to mess around, it won't affect production data. The Vercel preview build automatically points to the linked Xata database. 🎉
Vercel
botcommented 3 minutes ago on GitHub
The latest updates on your project. Learn more about Vercel for GitHub.
Name | State | Preview |
---|---|---|
my-website | ✅ Ready | View on Xata |
Merge your pull request as usual. Our system will run checks, perform a zero-downtime migration, and close any open branches, automatically.
Alexis
merged commit3daa381
into main
just nowXata
botnoticed a merge. Deleting branchpreview-my-changes
Xata
botnoticed a merge. Merging branchmy-changes
to main
Merged the pull request. Xata automatically merged the database changes to the main
branch with zero downtime.
Work with any frontend. Branch your database like your code. Offer real-time search or integrated AI. Preview and deploy to Netlify and Vercel, just like a static website.
Join tens of thousands of developers who are working with Xata to build better products
Guillermo Rauch
@rauchg
Founder & CEO, Vercel
This is the new gold standard for frontend and backend workflow.
Preview your @vercel frontend alongside your @xata base, with schema changes and automatic (and safe!) data staging.
Matt Pocock
@mattpocockuk
TypeScript Educator
Matt Biilmann
@biilmann
CEO, Netlify
Benedicte (Queen) Raae 👑
@raae
Dominus Kelvin
@K.O.O
Web Dev Educator
Neha Narkhede
@nehanarkhede
Co-Founder, Confluent
Zeno Rocha
@zenorocha
Founder & CEO at resend.com
Mohamed Sahel
@james_r_perkins
Full Stack Developer