SurrealDB stores relational, document, graph, time-series, vector and full-text data in one engine, queried through SurrealQL and reachable from ten official SDKs. It runs embedded in your application, as a single node, or as a distributed cluster, and SurrealDB Cloud runs it for you, on dedicated instances or serverless on SurrealDB Earth .
Set me up for SurrealDB. Fetch https://surrealdb.com/docs/agents/instructions.md and follow it.
Your agent installs SurrealDB's Agent Skills and connects to the SurrealDB MCP server, ready to write SurrealQL against a real database.
Setup steps for each agent Where do you want to start?If you have not used a database before, Database basics explains the ideas that the rest of the documentation builds on.
Your first querySurrealQL is SQL-shaped, so most of it reads as you would expect. What it adds is the ability to relate records directly and traverse those relations in the same statement, without a join table or a second database. Edit and run this:
The querying guide covers the language properly, and data models covers what else the engine stores.
Connect from your languageChoose a language to see how a first connection looks, then continue in that language's quickstart, which goes on to insert and query data.
Rust JavaScript Python Go .NET Java Kotlin PHP Swift Mojo
cargo add surrealdb --features kv-mem,protocol-ws
cargo add tokio --features macros,rt-multi-thread use surrealdb :: engine :: remote :: ws :: Ws ;
use surrealdb :: opt :: auth :: Root ;
use surrealdb :: Surreal ;
# [ tokio :: main ]
async fn main ( ) -> surrealdb :: Result < ( ) > {
let db = Surreal :: new :: < Ws > ( "127.0.0.1:8000" ) . await ? ;
db . signin ( Root {
username : "root" . to_string ( ) ,
password : "secret" . to_string ( ) ,
} )
. await ? ;
db . use_ns ( "main" ) . use_db ( "main" ) . await ? ;
Ok ( ( ) )
} The Rust quickstart continues with inserting and querying data, and the Rust SDK reference covers every method.
npm install --save surrealdb import { Surreal } from 'surrealdb' ;
const db = new Surreal ( ) ;
await db . connect ( 'ws://localhost:8000' , {
namespace : "main" ,
database : "main" ,
authentication : {
username : 'root' ,
password : 'secret'
}
} ) ; The JavaScript quickstart continues with inserting and querying data, and the installation guide covers other package managers.
from surrealdb import Surreal
db = Surreal ( "ws://localhost:8000" )
db . connect ( )
db . signin ( { "username" : "root" , "password" : "secret" } )
db . use ( "main" , "main" ) The Python quickstart continues with inserting and querying data, and shows the asynchronous client. The installation guide covers other package managers.
go get github.com/surrealdb/surrealdb.go/v2 ctx := context . Background ( )
db , err := surrealdb . FromEndpointURLString ( ctx , "ws://localhost:8000" )
if err != nil {
log . Fatal ( err )
}
defer db . Close ( ctx )
_ , err = db . SignIn ( ctx , surrealdb . Auth {
Username : "root" ,
Password : "secret" ,
} )
if err != nil {
log . Fatal ( err )
}
if err := db . Use ( ctx , "main" , "main" ) ; err != nil {
log . Fatal ( err )
} The Go quickstart continues with inserting and querying data, and the installation guide covers versions.
dotnet add package SurrealDb.Net using SurrealDb . Net ;
using SurrealDb . Net . Models . Auth ;
using var db = new SurrealDbClient ( "ws://127.0.0.1:8000/rpc" );
await db . SignIn ( new RootAuth { Username = "root" , Password = "secret" });
await db . Use ( "main" , "main" ); The .NET quickstart continues with inserting and querying data, and the .NET SDK reference covers every method.
import com . surrealdb . Surreal ;
import com . surrealdb . signin . RootCredential ;
try ( Surreal db = new Surreal ()) {
db . connect ( "ws://localhost:8000" );
db . useNs ( "main" ). useDb ( "main" );
db . signin ( new RootCredential ( "root" , "secret" ));
} Add the SDK to your build as described in the installation guide . The Java quickstart continues with inserting and querying data.
import com.surrealdb.kotlin.SurrealClient
import com.surrealdb.kotlin.SurrealClientConfig
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
fun main() = runBlocking {
val client = SurrealClient(SurrealClientConfig(url = "ws://localhost:8000"))
client.signin(buildJsonObject {
put("user", "root")
put("pass", "secret")
})
client.use("surrealdb", "docs")
client.close()
} Add the SDK to your build as described in the installation guide . The Kotlin quickstart continues with inserting and querying data.
composer require surrealdb/surrealdb.php:^1.0 require __DIR__ . '/vendor/autoload.php' ;
use Surreal \ Surreal ;
$db = new Surreal ( ) ;
$db -> connect ( "ws://127.0.0.1:8000/rpc" ) ;
$db -> use ( [
"namespace" => "surrealdb" ,
"database" => "docs" ,
] ) ;
$token = $db -> signin ( [
"username" => "root" ,
"password" => "secret" ,
] ) ; The PHP quickstart continues with inserting and querying data, and the installation guide covers the autoloader.
import SurrealDB
let client = try SurrealHTTPClient(endpoint: "http://localhost:8000")
try await client.connect()
defer { Task { await client.close() } }
let tokens = try await client.signin(.root(username: "root", password: "secret"))
try await client.use(namespace: "myapp", database: "mydb") Add the package as described in the installation guide . The Swift quickstart continues with inserting and querying data.
from surrealdb import AsyncSurrealClient , ConnectOptions
from std . collections import Optional
def main ( ) :
var client = AsyncSurrealClient ( )
_ = client . connect (
"http://localhost:8000/rpc" ,
ConnectOptions (
namespace = Optional ( String ( "test" ) ) ,
database = Optional ( String ( "test" ) ) ,
access_token = Optional ( String ( "Basic cm9vdDpzZWNyZXQ=" ) ) , # root:secret
) ,
) Build the SDK as described in the installation guide . The Mojo quickstart continues with inserting and querying data.
Each tab holds the first connection from that language's quickstart, which stays the full guide. The SDKs page lists all ten, community SDKs cover further languages, and the React Native and Expo guide covers mobile.
Run it somewhere The rest of the documentationDatabase basics, querying, schema, data models, security, and tutorials and demos.
Integrations, AI agents, embedding, and migrating from another database.
SurrealDB Cloud, Earth, organisations, enterprises, observability, self-hosting and upgrades.
SurrealQL, protocols, the CLI, Studio and SDK methods.
The memory and knowledge layer for AI agents.