API Guide

Loading the Schema

The examples in this guide are using the following schema:

To create a database with this schema, install the Xata CLI, create a tutorial folder:

Then save the JSON above in a file called schema.json and run:

When prompted, choose to create a new database and name it tutorial. You can accept the defaults for the rest of the questions.

Running the Examples

This guide contains examples using the TypeScript/Javascript SDK as well as examples using the REST API directly, which can be used with any programming language.

If you want to try out the TypeScript/Javascript SDK examples, you can use the built-in Playground.

If you want to try out the REST API examples, you can either use a visual HTTP client like Postman, Insomnia, or a CLI client like curl. In this case, you will need to send Authorization and Content-Type headers like this:

The URL of your database is based on the Workspace API base URL, which you can get from the Configuration page of your Workspace. Replace the {region} and {database} sections with the actual region and name of your database, followed by a colon with the branch and the relevant URI endpoint. You can consult the API Reference section in the documentation for details about the URI endpoint and request body where applicable.

Tip: You can click the Get Code Snippet in the UI and then select curl to see the correct URL to use.

On this page

Loading the Schema

Running the Examples