HTTP & Rest
The HTTP endpoints enable simple selection and modifications of all records or a single record in a table, in addition to support for custom SurrealQL queries with multiple statements, using traditional RESTful HTTP url endpoints.
Accessing Endpoints via Postman
You can access these endpoints via Postman. To do so, follow these steps:
- Open Postman
- Clone the SurrealDB Postman Collection
- Select the appropriate HTTP method (GET, POST, etc.).
- Enter the endpoint URL.
- If the endpoint requires any parameters or a body, make sure to include those in your request.
Note: Ensure that your URL is set correctly, if running locally, the URL should be http://localhost:8000
.By default, the URL is set to local. Start your server using the Start command in the CLI, before querying the endpoints.
You can use the HTTP endpoints to perform the following actions:
Function | Description |
---|---|
GET /status | Checks whether the database web server is running |
GET /health | Checks the status of the database server and storage engine |
GET /version | Returns the version of the SurrealDB database server |
POST /import | Imports data into a specific Namespace and Database |
GET /export | Exports all data for a specific Namespace and Database |
POST /signup | Signs-up as a scope user to a specific scope |
POST /signin | Signs-in as a root, namespace, database, or scope user |
GET /key/:table | Selects all records in a table from the database |
POST /key/:table | Creates a records in a table in the database |
PUT /key/:table | Updates all records in a table in the database |
PATCH /key/:table | Modifies all records in a table in the database |
DELETE /key/:table | Deletes all records in a table from the database |
GET /key/:table/:id | Selects the specific record from the database |
POST /key/:table/:id | Creates the specific record in the database |
PUT /key/:table/:id | Updates the specified record in the database |
PATCH /key/:table/:id | Modifies the specified record in the database |
DELETE /key/:table/:id | Deletes the specified record from the database |
POST /sql | Allows custom SurrealQL queries |
POST /ml/import | Import a SurrealML model into a specific Namespace and Database |
GET /ml/export/:name/:version | Export a SurrealML model from a specific Namespace and Database |
GET /status
This HTTP RESTful endpoint checks whether the database web server is running, returning a 200 status code.
GET /health
This HTTP RESTful endpoint checks whether the database server and storage engine are running.
The endpoint returns a 200
status code on success and a 500
status code on failure.
GET /version
This HTTP RESTful endpoint returns the version of the SurrealDB database server.
POST /import
This HTTP RESTful endpoint imports a set of SurrealQL queries into a specific Namespace and Database.
Headers
Header | Description | ||
---|---|---|---|
Authorization | Sets the root, namespace, or database authentication data | ||
Accept | Sets the desired content-type of the response | ||
NS | Sets the selected Namespace for queries | ||
DB | Sets the selected Database for queries |
Example usage
Requestcurl -X POST -u "root:root" -H "NS: mynamespace" -H "DB: mydatabase" -H "Accept: application/json" -d path/to/file.surql http://localhost:8000/import
GET /export
This HTTP RESTful endpoint exports all data for a specific Namespace and Database.