SurrealDB provides a RESTful HTTP API for interacting with the database programmatically. This is useful when you need to integrate SurrealDB into existing HTTP-based workflows, scripts, or environments where an SDK is not available.
Using curl POST /sql
The /sql endpoint enables use of SurrealQL queries.
Important
Headers
| Header | Description |
|---|---|
Authorization
| Sets the root, namespace, database, or record authentication data |
Accept
| Sets the desired content-type of the response |
surreal-ns
| Sets the selected Namespace for queries. |
surreal-db
| Sets the selected Database for queries. |
Example usage
Important
Using Postman
Postman is a popular tool for testing APIs. You can use it to send HTTP requests to your SurrealDB instance and perform various database operations.
Set up Postman: Download and install Postman from the official website.
Create a new request: Open Postman and create a new HTTP request.
Configure the request:
Set the request method to
POST.Enter the URL of your SurrealDB instance, e.g.,
http://localhost:8000/sql.In the headers section, add a
Content-Typeheader with the valueapplication/json.In the Body section, select
rawand set the type toText. Enter your SQL query, for example:
Send the request: Click the
Sendbutton to execute the query. You will see the response from SurrealDB in the lower section of the Postman interface.
Learn more
Learn more about other HTTP Endpoints available in SurrealDB. For a more detailed tutorial on using Postman with SurrealDB, refer to the working with SurrealDB over HTTP via Postman tutorial.