# Quick Start

> Get started with SlateDB in minutes

SlateDB is implemented in Rust and ships official bindings for Go, Java, Node.js, and Python. Pick your language below to install the library and run a minimal example backed by an in-memory object store.

## Installation

### Rust

```bash
cargo add slatedb tokio --features tokio/macros,tokio/rt-multi-thread
```

### Go

```bash
go get slatedb.io/slatedb-go
```

The Go binding uses cgo and links against the `slatedb_uniffi` shared library. You need Go 1.25+, `CGO_ENABLED=1`, a C toolchain, and the `slatedb_uniffi` library on your loader path.

### Java

Gradle:

```gradle
dependencies {
    implementation("io.slatedb:slatedb-uniffi:<version>")
}
```

Maven:

```xml
<dependency>
  <groupId>io.slatedb</groupId>
  <artifactId>slatedb-uniffi</artifactId>
  <version>&lt;version&gt;</version>
</dependency>
```

Requires Java 22 or newer.

### Node.js

```bash
npm install @slatedb/uniffi
```

Requires Node.js 20 or newer.

### Python

```bash
pip install slatedb
```

Requires Python 3.10 or newer.

## Usage

SlateDB reads and writes through an object store. Every binding exposes `ObjectStore.resolve(...)` (or `InMemory::new()` in Rust) which accepts any URL supported by Rust's [`object_store`](https://docs.rs/object_store/latest/object_store/fn.parse_url_opts.html) crate, including `memory:///`, `file:///...`, `s3://`, `gs://`, and `az://`. The examples below use `memory:///` so they run without any external setup.

### Rust

SlateDB uses [`tokio`](https://crates.io/crates/tokio) as its async runtime and [`object_store`](https://docs.rs/object_store/latest/object_store/) to interact with object storage.

<!-- could not inline /home/runner/work/slatedb/examples/src/full_example.rs -->

### Go

```go
package main
async function main() {
  const store = ObjectStore.resolve("memory:///");
  let db;

  try {
    const builder = new DbBuilder("demo-db", store);
    try {
      db = await builder.build();
    } finally {
      builder.dispose();
    }

    const key = Buffer.from("hello");
    const value = Buffer.from("world");

    await db.put(key, value);

    const read = await db.get(key);
    assert.deepEqual(read, value);

    console.log(Buffer.from(read).toString("utf8"));
  } finally {
    if (db != null) {
      await db.shutdown();
      db.dispose();
    }
    store.dispose();
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
```

### Python

Most database operations are `async` and should be used with `asyncio`. `WriteBatch` is mutated synchronously and then consumed by `db.write(...)`. Call `db.shutdown()` to close native resources.

```python
import asyncio

from slatedb.uniffi import (
    DbBuilder,
    IsolationLevel,
    ObjectStore,
    WriteBatch,
)

async def main() -> None:
    store = ObjectStore.resolve("memory:///")
    builder = DbBuilder("demo-db", store)
    db = await builder.build()

    try:
        await db.put(b"user:1", b"Alice")
        value = await db.get(b"user:1")
        assert value == b"Alice"

        batch = WriteBatch()
        batch.put(b"user:2", b"Bob")
        batch.put(b"user:3", b"Carol")
        await db.write(batch)

        scan = await db.scan_prefix(b"user:")
        while (row := await scan.next()) is not None:
            print(row.key, row.value)

        tx = await db.begin(IsolationLevel.SERIALIZABLE_SNAPSHOT)
        await tx.put(b"user:4", b"Dora")
        await tx.commit()
    finally:
        await db.shutdown()

asyncio.run(main())
```
