Let’s get your backend code talking to StatelyDB so you can start reading and writing data .
Prerequisites
Create a Stately account and a Store
Install an SDK for your language
Define a schema and generate language-specific code
Creating a Client
When you generated code for your schema , you got a customized client creation function that knows about all of your schema’s types. You can import that function to create a client, and then use that client from your backend code to interact with StatelyDB.
To authenticate your client to the StatelyDB service, you will need an Access Key. You can create access keys in the console by clicking “Manage Access Keys”. The access key is a secret that can be passed explicitly when creating a client, or it will be picked up automatically from a STATELY_ACCESS_KEY
environment variable.
You will also need to specify your Store ID and the region for your store. Both of those are available in the console, or by running stately whoami
with the CLI.
" github.com/StatelyCloud/go-sdk/stately "
// This is the code you generated from schema
" github.com/StatelyCloud/stately/go-sdk-sample/schema "
// Create a client for interacting with a Store.
func makeClient () stately.Client {
// This uses the generated "NewClient" func in your schema package.
dataClient , err := schema . NewClient (
& stately.Options{ Region : " us-west-2 " },
panic ( " failed to build StatelyDB client: " + err . Error ())
# This is the code you generated from schema
require_relative " ./schema/stately "
client = StatelyDB :: Client . new ( store_id: 12345 , region: " us-west-2 " )
# This is the code you generated from schema
from .schema import Client
client = Client ( store_id = 12345 , region = " us-west-2 " )
// This is the code you generated from schema
import { createClient } from " ./schema/index.js " ;
// Create a Data client for interacting with a Store
const client = createClient (
Providing an explicit Access Key
If you don’t want your access key to be read from environment variables, you can provide them explicitly:
" github.com/StatelyCloud/go-sdk/stately "
// This is the code you generated from schema
" github.com/StatelyCloud/stately/go-sdk-sample/schema "
// Create a client for interacting with a Store.
func makeClientWithCredentials () stately.Client {
// Use the generated "NewClient" func in your schema package.
dataClient , err := schema . NewClient (
AccessKey : " my-access-key " ,
panic ( " failed to build StatelyDB client: " + err . Error ())
# This is the code you generated from schema
require_relative " ./schema/stately "
client = StatelyDB :: Client . new (
token_provider: StatelyDB :: Common :: Auth :: AuthTokenProvider . new (
access_key: " my-access-key "
from statelydb import init_server_auth
# This is the code you generated from schema
from .schema import Client
token_provider = init_server_auth (
access_key = " my-access-key " ,
import { accessKeyAuth } from " @stately-cloud/client " ;
// This is the code you generated from schema
import { createClient } from " ./schema/index.js " ;
// Create a Data client for interacting with a Store
const client = createClient (
authTokenProvider: accessKeyAuth ( {
accessKey: " my-access-key " ,