# Quick start

This Quick Start guide walks you through the essentials of deploying an Aerospike Database and building a simple application to interact with it. You’ll learn how to quickly spin up a local development environment using Docker, set up your project in your preferred programming language, connect to the database, and perform basic read and write operations.

::: tip
This Quick Start assumes a basic understanding of application development and experience issuing commands in a terminal.
:::

## Deploy Aerospike with Docker

The quickest and easiest way to get up and running quickly is with [Docker](https://hub.docker.com/_/aerospike).

The following command creates a single node Aerospike Enterprise database, using the latest version, equipped with a single node feature key and template configuration. No additional setup is needed.

Terminal window

```bash
docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server:latest
```

If you’d like to customize your deployment, see [configuring Aerospike](https://aerospike.com/docs/database/manage/database/as-config) for more information. Aerospike has a variety of options when it comes to deploying the database.

-   [AeroLab](https://github.com/aerospike/aerolab) is a community-supported tool for quickly spinning up development clusters.
-   You can deploy containers directly using [Docker](https://aerospike.com/docs/database/install/docker) or [Kubernetes Operator](https://aerospike.com/docs/kubernetes).
-   Aerospike supports the three major cloud providers, [AWS](https://aerospike.com/docs/database/install/aws/install), [GCP](https://aerospike.com/docs/database/install/gcp/install), and [Azure](https://aerospike.com/docs/database/install/azure/install).
-   Bare metal deployments are available with a variety of [Linux distributions](https://aerospike.com/docs/database/install/linux) as well.

## Set up your development environment

Grab your favorite IDE and create a new project.

-   [Java](#tab-panel-625)
-   [C#](#tab-panel-626)
-   [Go](#tab-panel-627)
-   [Python](#tab-panel-628)
-   [Node.js](#tab-panel-629)

For this quick start we’ll be using Maven for our build manager. After creating your project, add the following dependency to the `pom.xml` file.

```xml
<dependencies>

    <dependency>

        <groupId>com.aerospike</groupId>

        <artifactId>aerospike-client</artifactId>

        <version>7.0.0</version>

    </dependency>

</dependencies>
```

If you’re using a different build manager, or looking for more information on getting started with the Java client, check out the [Java client install](https://aerospike.com/docs/develop/client/java/install/) docs.

The compiled C# client library dll is available on [NuGet](https://www.nuget.org/packages/Aerospike.Client). To install, run the following command in the [Package Manager Console](https://docs.nuget.org/docs/start-here/using-the-package-manager-console).

Terminal window

```powershell
PM> Install-Package Aerospike.Client
```

If you’re looking for more information on getting started with the C# client, check out the [C# client install](https://aerospike.com/docs/develop/client/csharp/install) docs.

After [setting up your Go project](https://go.dev/doc/code), run the following to get the Aerospike Go Client in your `$GOPATH`.

Terminal window

```bash
go get github.com/aerospike/aerospike-client-go/v8@v8.5.0

go run -tags as_proxy main.go
```

If you’re looking for more information on getting started with the Go client, check out the [Go client install](https://aerospike.com/docs/develop/client/go/install) docs.

Using Python3 and `pip`, run the following command to install the Aerospike client.

Terminal window

```bash
python3 -m pip install aerospike
```

If you’re looking for more information on getting started with the Python client, check out the [Python client install](https://aerospike.com/docs/develop/client/python/install/) docs.

Using [npm](https://www.npmjs.com/) to install Aerospike, run the following command inside your project directory.

Terminal window

```bash
npm install aerospike
```

If you’re looking for more information on getting started with the Node.js client, check out the [Node.js client install](https://aerospike.com/docs/develop/client/node/install) docs.

## Application basics

The following code block contains the necessary imports and basic application shell to get started.

-   [Java](#tab-panel-630)
-   [C#](#tab-panel-631)
-   [Go](#tab-panel-632)
-   [Python](#tab-panel-633)
-   [Node.js](#tab-panel-634)

```java
package com.sample;

import com.aerospike.client.IAerospikeClient;

import com.aerospike.client.AerospikeClient;

import com.aerospike.client.AerospikeException;

import com.aerospike.client.Bin;

import com.aerospike.client.Host;

import com.aerospike.client.Key;

import com.aerospike.client.Record;

import com.aerospike.client.policy.WritePolicy;

import com.aerospike.client.policy.Policy;

public class App

{

    public static void main( String[] args )

    {

    }

}
```

```csharp
using System;

using Aerospike.Client;

public class App

{

    public static void main()

    {

    }

}
```

```go
package main

import (

  "log"

  "time"

  "github.com/aerospike/aerospike-client-go/v8@v8.5.0"

)

func main() {

}
```

```python
import aerospike

from aerospike import exception as ex
```

```js
const Aerospike = require('aerospike');

const main = async () => {

}

main();
```

## Client connection

The minimum information you need to connect to an Aerospike database is the server `IP address` and `port number`. If you’re using the basic Docker install from step one, the following information should work just fine.

If your database is deployed with a cloud provider or installed elsewhere, you’ll need information specific to your cluster setup.

Create variables to store the connection information, as well as the [namespace](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#namespaces) and [set name](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#sets).

Using the `address` and `port` from above, instantiate the Aerospike client.

-   [Java](#tab-panel-635)
-   [C#](#tab-panel-636)
-   [Go](#tab-panel-637)
-   [Python](#tab-panel-638)
-   [Node.js](#tab-panel-639)

```java
String address = "127.0.0.1";   // Aerospike address

Integer port = 3000;            // Aerospike port

String namespace = "test";      // Cluster namespace

String set = "foo";             // Set name within namespace

IAerospikeClient client = new AerospikeClient(address, port);
```

```csharp
string address = "127.0.0.1";   // Aerospike address

int port = 3000;                // Aerospike port

string name_space = "test";     // Cluster namespace

string set = "foo";             // Set name within namespace

AerospikeClient client = new AerospikeClient(null, new Host(address, port));
```

```go
address := "127.0.0.1"          // Aerospike address

port := 3000                    // Aerospike port

namespace := "test"             // Cluster namespace

set := "foo"                    // Set name within namespace

// Create the client and connect to the database

client, err := aerospike.NewClient(address, port)

if err != nil {

    log.Fatal(err)

}

defer client.Close()
```

```python
address = "127.0.0.1"   # Aerospike address

port = 3000       # Aerospike port

namespace = "test"      # Cluster namespace

setname = "foo"      # Set name within namespace

client = aerospike.client({'hosts': [(address, port)]})
```

```js
const address = "127.0.0.1";    // Aerospike address

const port = "3000";            // Aerospike port

const namespace = "test";       // Cluster namespace

const set = "foo";              // Set name within namespace

let client = await Aerospike.connect({ hosts: `${address}:${port}` });
```

## Write a record

-   [Java](#tab-panel-645)
-   [C#](#tab-panel-646)
-   [Go](#tab-panel-647)
-   [Python](#tab-panel-648)
-   [Node.js](#tab-panel-649)

1.  Create a `WritePolicy` to set the `totalTimeout` for writes.
    
    ```java
    WritePolicy writePolicy = new WritePolicy();
    
    writePolicy.totalTimeout = 5000;
    ```
    
2.  Create the record [key](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#keys-and-digests), a tuple consisting of namespace, set name, and user defined key
    
    ```java
    Key key = new Key(namespace, set, "bar");
    ```
    
3.  Create a [bin](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#bins-and-data-types) to store data within the new record
    
    ```java
    Bin bin = new Bin("myBin", "Hello World!");
    ```
    
4.  Write the record to Aerospike.
    
    ```java
    try {
    
        client.put(writePolicy, key, bin);
    
        System.out.println("Successfully wrote record");
    
    }
    
    catch (AerospikeException e) {
    
        e.printStackTrace();
    
    }
    ```
    

1.  Create a `WritePolicy` to set the `totalTimeout` for writes.
    
    ```csharp
    WritePolicy writePolicy = new WritePolicy();
    
    writePolicy.totalTimeout = 5000;
    ```
    
2.  Create the record [key](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#keys-and-digests), a tuple consisting of namespace, set name, and user defined key
    
    ```csharp
    Key key = new Key(name_space, set, "bar");
    ```
    
3.  Create a [bin](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#bins-and-data-types) to store data within the new record
    
    ```csharp
    Bin bin = new Bin("myBin", "Hello World!");
    ```
    
4.  Write the record to Aerospike.
    
    ```csharp
    try
    
    {
    
        client.Put(writePolicy, key, bin);
    
        Console.WriteLine("Successfully wrote record");
    
    }
    
    catch (AerospikeException e)
    
    {
    
        Console.WriteLine(e);
    
    }
    ```
    

1.  Create a `WritePolicy` to set the `TotalTimeout` for writes.
    
    ```go
    writePolicy := aerospike.NewWritePolicy(0, 0)
    
    writePolicy.TotalTimeout = 5000 * time.Millisecond
    ```
    
2.  Create the record [key](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#keys-and-digests), a tuple consisting of namespace, set name, and user defined key
    
    ```go
    key, err := aerospike.NewKey(namespace, set, "bar")
    
    if err != nil {
    
        log.Fatal(err)
    
    }
    ```
    
3.  Create a [bin](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#bins-and-data-types) to store data within the new record
    
    ```go
    bin := aerospike.NewBin("myBin", "Hello World!")
    ```
    
4.  Write the record to Aerospike.
    
    ```go
    err = client.PutBins(writePolicy, key, bin)
    
    if err != nil {
    
        log.Fatal(err)
    
    }
    
    log.Println("Succesfully wrote record")
    ```
    

1.  Create a `WritePolicy` to set the `totalTimeout` for writes.
    
    ```python
    write_policy = {'total_timeout': 5000}
    ```
    
2.  Create the record [key](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#keys-and-digests), a tuple consisting of namespace, set name, and user defined key
    
    ```python
    key = (namespace, setname, "bar")
    ```
    
3.  Create a [bin](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#bins-and-data-types) to store data within the new record
    
    ```python
    bins = {'myBin': 'Hello World!'}
    ```
    
4.  Write the record to Aerospike.
    
    ```python
    try:
    
        client.put(key, bins, policy=write_policy)
    
        print("Successfully wrote record")
    
    except ex.ClientError as e:
    
        print(e)
    ```
    

1.  Create a `WritePolicy` to set the `totalTimeout` for writes.
    
    ```js
    let writePolicy = new Aerospike.WritePolicy({
    
        totalTimeout: 5000
    
    });
    ```
    
2.  Create the record [key](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#keys-and-digests), a tuple consisting of namespace, set name, and user defined key
    
    ```js
    let key = new Aerospike.Key(namespace, set, "bar");
    ```
    
3.  Create a [bin](https://aerospike.com/docs/database/learn/architecture/data-storage/data-model/#bins-and-data-types) to store data within the new record
    
    ```js
    let bin = { myBin: "Hello World!" };
    ```
    
4.  Write the record to Aerospike.
    
    ```js
    try {
    
        await client.put(key, bin, [], writePolicy);
    
        console.info("Successfully wrote record");
    
    }
    
    catch (err) {
    
        console.error(err);
    
    }
    ```
    

## Read a record

-   [Java](#tab-panel-650)
-   [C#](#tab-panel-651)
-   [Go](#tab-panel-652)
-   [Python](#tab-panel-653)
-   [Node.js](#tab-panel-654)

1.  Create a `Policy` to set the `totalTimeout` for reads.
    
    ```java
    Policy readPolicy = new Policy();
    
    readPolicy.totalTimeout = 5000;
    ```
    
2.  Using the same key from our write command, read the record back.
    
    ```java
    try {
    
        Record record = client.get(readPolicy, key);
    
        System.out.format("Record: %s", record.bins);
    
    }
    
    catch (AerospikeException e) {
    
        e.printStackTrace();
    
    }
    
    finally {
    
        client.close();
    
    }
    ```
    

1.  Create a `Policy` to set the `totalTimeout` for reads.
    
    ```csharp
    Policy readPolicy = new Policy();
    
    readPolicy.totalTimeout = 5000;
    ```
    
2.  Using the same key from our write command, read the record back.
    
    ```csharp
    try
    
    {
    
        client.Get(readPolicy, key);
    
        Console.WriteLine("Record: {0}", record);
    
    }
    
    catch (AerospikeException e)
    
    {
    
        Console.WriteLine(e);
    
    }
    
    finally
    
    {
    
        client.Close();
    
    }
    ```
    

1.  Create a `Policy` to set the `TotalTimeout` for reads.
    
    ```go
    readPolicy := aerospike.NewPolicy()
    
    readPolicy.TotalTimeout = 5000 * time.Millisecond
    ```
    
2.  Read the record.
    
    ```go
    record, err := client.Get(readPolicy, key)
    
    if err != nil {
    
        log.Fatal(err)
    
    }
    
    log.Printf("Record: %s", record.Bins)
    ```
    

1.  Create a `Policy` to set the `totalTimeout` for reads.
    
    ```python
    read_policy = {'total_timeout': 5000}
    ```
    
2.  Using the same key from our write command, read the record back.
    
    ```python
    try:
    
        (key_, meta, bins) = client.get(key, policy=read_policy)
    
        print(bins)
    
    except ex.ClientError as e:
    
        print(e)
    
    finally:
    
        client.close()
    ```
    

1.  Create a `Policy` to set the `totalTimeout` for reads.
    
    ```js
    let readPolicy = new Aerospike.ReadPolicy({
    
        totalTimeout: 5000
    
    });
    ```
    
2.  Using the same key from our write command, read the record back.
    
    ```js
    try {
    
        let record = await client.get(key, readPolicy);
    
        console.info("Record: %o", record);
    
    }
    
    catch (err) {
    
        console.error(err);
    
    }
    
    finally {
    
        client.close();
    
    }
    ```
    

Check out the [Develop](https://aerospike.com/docs/develop/) topic for more in-depth code samples and content to help you get started!

## Put it all together

Check out the full code sample

-   [Java](#tab-panel-640)
-   [C#](#tab-panel-641)
-   [Go](#tab-panel-642)
-   [Python](#tab-panel-643)
-   [Node.js](#tab-panel-644)

```java
package com.sample;

import com.aerospike.client.IAerospikeClient;

import com.aerospike.client.AerospikeClient;

import com.aerospike.client.AerospikeException;

import com.aerospike.client.Bin;

import com.aerospike.client.Host;

import com.aerospike.client.Key;

import com.aerospike.client.Record;

import com.aerospike.client.policy.WritePolicy;

import com.aerospike.client.policy.Policy;

public class App

{

    public static void main( String[] args )

    {

        // ***

        // Setup

        // ***

        String address = "127.0.0.1";   // Aerospike address

        Integer port = 3000;            // Aerospike port

        String namespace = "test";      // Cluster namespace

        String set = "foo";             // Set name within namespace

        // Create the client and connect to the database

        IAerospikeClient client = new AerospikeClient(address, port);

        // ***

        // Write a record

        // ***

        // Create a new write policy

        WritePolicy writePolicy = new WritePolicy();

        writePolicy.totalTimeout = 5000;

        // Create the record key

        // A tuple consisting of namespace, set name, and user defined key

        Key key = new Key(namespace, set, "bar");

        // Create a bin to store data within the new record

        Bin bin = new Bin("myBin", "Hello World!");

        //Write the record to your database

        try {

            client.put(writePolicy, key, bin);

            System.out.println("Successfully wrote record");

        }

        catch (AerospikeException e) {

            e.printStackTrace();

        }

        // ***

        // Read back the record we just wrote

        // ***

        // Create a new read policy

        Policy readPolicy = new Policy();

        readPolicy.totalTimeout = 5000;

        // Read the record

        try {

            Record record = client.get(readPolicy, key);

            System.out.format("Record: %s", record.bins);

        }

        catch (AerospikeException e) {

            e.printStackTrace();

        }

        finally {

            client.close();

        }

    }

}
```

```csharp
using System;

using Aerospike.Client;

public class App

{

    public static void main()

    {

        // ***

        // Setup

        // ***

        string address = "127.0.0.1";   // Aerospike address

        int port = 3000;                // Aerospike port

        string namespace = "test";      // Cluster namespace

        string set = "foo";             // Set name within namespace

        // Create the client and connect to the database

        AerospikeClient client = new AerospikeClient(null, new Host(address, port));

        // ***

        // Write a record

        // ***

        // Create a new write policy

        WritePolicy writePolicy = new WritePolicy();

        writePolicy.totalTimeout = 5000;

        // Create the record key

        // A tuple consisting of namespace, set name, and user defined key

        Key key = new Key(namespace, set, "bar");

        // Create a bin to store data within the new record

        Bin bin = new Bin("myBin", "Hello World!");

        //Write the record to your database

        try

        {

            client.Put(writePolicy, key, bin);

            Console.WriteLine("Successfully wrote record");

        }

        catch (AerospikeException e)

        {

            Console.WriteLine(e);

        }

        // ***

        // Read back the record we just wrote

        // ***

        // Create a new read policy

        Policy readPolicy = new Policy();

        readPolicy.totalTimeout = 5000;

        // Read the record

        try

        {

            Record record = client.Get(readPolicy, key);

            Console.WriteLine("Record: {0}", record);

        }

        catch (AerospikeException e)

        {

            Console.WriteLine(e);

        }

        finally

        {

            client.Close();

        }

    }

}
```

```go
package main

import (

  "log"

  "time"

  "github.com/aerospike/aerospike-client-go/v8@v8.5.0"

)

func main() {

  // ***

  // Setup

  // ***

  address := "127.0.0.1"      // Aerospike address

  port := 3000                // Aerospike port

  namespace := "test"         // Cluster namespace

  set := "foo"                // Set name within namespace

  // Create the client and connect to the database

  client, err := aerospike.NewClient(address, port)

  if err != nil {

    log.Fatal(err)

  }

  defer client.Close()

  // ***

  // Write a record

  // ***

  // Create a WritePolicy to set the TotalTimeout for writes

  // default 1000 ms

  writePolicy := aerospike.NewWritePolicy(0, 0)

  writePolicy.TotalTimeout = 5000 * time.Millisecond

  // Create the record key

  // A tuple consisting of namespace, set name, and user defined key

  key, err := aerospike.NewKey(namespace, set, "bar")

  if err != nil {

    log.Fatal(err)

  }

  // Create a bin to store data within the new record

  bin := aerospike.NewBin("myBin", "Hello World!")

  //Write the record to your database

  err = client.PutBins(writePolicy, key, bin)

  if err != nil {

    log.Fatal(err)

  }

  log.Println("Succesfully wrote record")

  // ***

  // Read back the record we just wrote

  // ***

  // Create a Policy to set the TotalTimeout for reads

  // default 1000 ms

  readPolicy := aerospike.NewPolicy()

  readPolicy.TotalTimeout = 5000 * time.Millisecond

  // Read the record

  record, err := client.Get(readPolicy, key)

  if err != nil {

    log.Fatal(err)

  }

  log.Printf("Record: %s", record.Bins)

}
```

```python
import aerospike

# ***

# Setup

# ***

address = "127.0.0.1"       # Aerospike address

port = 3000                 # Aerospike port

namespace = "test"          # Cluster namespace

setname = "foo"             # Set name within namespace

# Create the client and connect to the database

client = aerospike.client({'hosts': [(address, port)]})

# ***

# Write a record

# ***

# Create a new write policy

write_policy = {'total_timeout': 5000}

# Create the record key

# A tuple consisting of namespace, set name, and user defined key

key = (namespace, setname, "bar")

# Create a bin to store data within the new record

bins = {'myBin': 'Hello World!'}

# Write the record to your database

try:

    client.put(key, bins, policy=write_policy)

    print("Successfully wrote record")

except ex.ClientError as e:

    print(e)

# ***

# Read back the record we just wrote

# ***

# Create a new read policy

read_policy = {'total_timeout': 5000}

# Read the record

try:

    (key_, meta, bins) = client.get(key, policy=read_policy)

    print(bins)

except ex.ClientError as e:

    print(e)

finally:

    client.close()
```

```js
const Aerospike = require('aerospike');

const main = async () => {

    // ***

    // Setup

    // ***

    const address = "127.0.0.1";    // Aerospike address

    const port = "3000";            // Aerospike port

    const namespace = "test";       // Cluster namespace

    const set = "foo";              // Set name within namespace

    // Create the client and connect to the database

    let client = await Aerospike.connect({ hosts: `${address}:${port}` });

    // ***

    // Write a record

    // ***

    // Create a new write policy

    let writePolicy = new Aerospike.WritePolicy({

        totalTimeout: 5000

    });

    // Create the record key

    // A tuple consisting of namespace, set name, and user defined key

    let key = new Aerospike.Key(namespace, set, "bar");

    // Create a bin to store data within the new record

    let bin = { myBin: "Hello World!" };

    //Write the record to your database

    try {

        await client.put(key, bin, [], writePolicy);

        console.info("Successfully wrote record");

    }

    catch (err) {

        console.error(err);

    }

    // ***

    // Read back the record we just wrote

    // ***

    // Create a new read policy

    let readPolicy = new Aerospike.ReadPolicy({

        totalTimeout: 5000

    });

    // Read the record

    try {

        let record = await client.get(key, readPolicy);

        console.info("Record: %o", record);

    }

    catch (err) {

        console.error(err);

    }

    finally {

        client.close();

    }

}

main();
```