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 both a Client ID
and Client Secret
. During this preview period you’ll have to get those by contacting [email protected] . These can be passed explicitly when creating a client, or they will be picked up automatically from STATELY_CLIENT_ID
and STATELY_CLIENT_SECRET
environment variables.
You will also need to specify your Store ID and the region for your store. Both of those are available in the web 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.item_types "
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 Client ID and Client Secret
If you don’t want Client ID and Client Secret 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 (
ClientID : " my-client-id " ,
ClientSecret : " my-client-secret " ,
panic ( " failed to build StatelyDB client: " + err . Error ())
# This is the code you generated from schema
require_relative " ./schema/stately.item_types "
client = StatelyDB :: Client . new (
token_provider: StatelyDB :: Common :: Auth :: Auth0TokenProvider . new (
client_id: " my-client-id " ,
client_secret: " my-client-secret "
from statelydb import init_server_auth
# This is the code you generated from schema
from .schema import Client
token_provider = init_server_auth (
client_id = " my-client-id " ,
client_secret = " my-client-secret " ,
import { initServerAuth } 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: initServerAuth ( {
clientID: " my-client-id " ,
clientSecret: " my-client-secret " ,