> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ditto.live/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting SDK Connection Details

To retrieve your SDK connection details ensure you have first:

1. Created A Ditto Portal Account - [Creating a Ditto Account](/cloud/portal/creating-a-ditto-account)
2. Created A Ditto Database - [Creating a New Database](/cloud/portal/creating-a-new-app)

After you've created your database, select it from the list.

On the `Connect` tab, you will see the following details under `Big peer connection information`:

* Database ID - The unique identifier for your database.
* Auth URL - This is the URL you will need to pass to your SDK to authenticate.
* Websocket URL - This is the URL you will need to pass to your SDK to initiate replication via Websocket to Ditto Server.

On the `Connect` tab, under `Authentication Mode`, if you are still using the default authentication settings, you will also see the `Online Playground Authentication Token`.
This token is used to authenticate your SDK to Ditto Server It allows you to explore Ditto platform features and functionality without the hassle of setting up your own authentication mechanism.

## Connecting an SDK

Below are some examples of how to connect an SDK to Ditto Server:

<CodeGroup>
  ```swift Swift theme={null}
  ditto = Ditto(
    identity: DittoIdentity.onlinePlayground(
      appID: "REPLACE_ME_WITH_YOUR_APP_ID",
      token: "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
      enableDittoCloudSync: false, // This is required to be set to false to use the correct URLs
      customAuthURL: URL(string: "REPLACE_ME_WITH_YOUR_AUTH_URL")
    )
  )

  ditto.updateTransportConfig { transportConfig in
    // Set the Ditto Websocket URL
    transportConfig.connect.webSocketURLs.insert("wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL")
  }

  // Disable DQL strict mode so that collection definitions are not required in DQL queries
  try await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false")

  do {
    try ditto.startSync()
  } catch {
    print(error.localizedDescription)
  }
  ```

  ```kotlin Kotlin theme={null}
  try {
      val androidDependencies = DefaultAndroidDittoDependencies(applicationContext)
      val identity =
          DittoIdentity.OnlinePlayground(
              dependencies = androidDependencies,
              appId = "REPLACE_ME_WITH_YOUR_APP_ID",
              token = "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
              customAuthUrl = "REPLACE_ME_WITH_YOUR_AUTH_URL",
              enableDittoCloudSync = false  // This is required to be set to false to use the correct URLs
          )

      ditto = Ditto(androidDependencies, identity)

      ditto?.updateTransportConfig { config ->
          config.connect.websocketUrls.add("REPLACE_ME_WITH_YOUR_WEBSOCKET_URL")
      }

      // Disable DQL strict mode so that collection definitions are not required in DQL queries
      ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false")
      
      ditto.startSync()
  } catch (e: DittoError) {
      Log.e("Ditto error", e.message!!)
  }
  ```

  ```dart Dart theme={null}

  await Ditto.init();

  final identity = OnlinePlaygroundIdentity(
      appId: "REPLACE_ME_WITH_YOUR_APP_ID",
      token: "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
      customAuthUrl: "REPLACE_ME_WITH_YOUR_AUTH_URL",
      enableDittoCloudSync: false // This is required to be set to false to use the correct URLs
  );
  final ditto = await Ditto.open(identity);

  ditto.updateTransportConfig((config) {
    // Set the Ditto Websocket URL
    config.connect.webSocketUrls.add("wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL");
  });

  // Disable DQL strict mode so that collection definitions are not required in DQL queries
  await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false");

  ditto.startSync();
  ```

  <CodeGroup>
    ```javascript JavaScript theme={null}
    await init();

    const ditto = new Ditto({
      type: "onlinePlayground",
      appID: "REPLACE_ME_WITH_YOUR_APP_ID",
      token: "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
      customAuthURL: "REPLACE_ME_WITH_YOUR_AUTH_URL",
      enableDittoCloudSync: false, // This is required to be set to false to use the correct URLs
    });

    ditto.updateTransportConfig((config) => {
      config.connect.websocketURLs.push(
        'wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL'
      );
    });

    // Disable DQL strict mode so that collection definitions are not required in DQL queries
    await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false");

    ditto.startSync();
    ```

    ```typescript TypeScript theme={null}
    import { init, Ditto, TransportConfig } from '@dittolive/ditto';

    await init();

    const ditto: Ditto = new Ditto({
      type: "onlinePlayground",
      appID: "REPLACE_ME_WITH_YOUR_APP_ID",
      token: "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
      customAuthURL: "REPLACE_ME_WITH_YOUR_AUTH_URL",
      enableDittoCloudSync: false, // This is required to be set to false to use the correct URLs
    });

    ditto.updateTransportConfig((config: TransportConfig) => {
      config.connect.websocketURLs.push(
        'wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL'
      );
    });

    // Disable DQL strict mode so that collection definitions are not required in DQL queries
    await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false");

    ditto.startSync();
    ```
  </CodeGroup>

  ```typescript TS theme={null}
  import { init, Ditto, TransportConfig } from '@dittolive/ditto'

  await init()

  const ditto = new Ditto({
    type: "onlinePlayground",
    appID: "REPLACE_ME_WITH_YOUR_APP_ID",
    token: "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
    customAuthURL: "REPLACE_ME_WITH_YOUR_AUTH_URL",
    enableDittoCloudSync: false, // This is required to be set to false to use the correct URLs
  })

  ditto.updateTransportConfig((config: TransportConfig): void => {
    config.connect.websocketURLs.push(
      'wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL'
    )
  })

  // Disable DQL strict mode so that collection definitions are not required in DQL queries
  await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false")

  ditto.startSync()
  ```

  ```java Java theme={null}
  import com.ditto.java.Ditto;
  import com.ditto.java.DittoFactory;
  import com.ditto.java.DittoConfig;
  import com.ditto.java.DittoAuthenticationProvider;

  try {
      // Configure Ditto with playground settings
      DittoConfig config = new DittoConfig.Builder("REPLACE_ME_WITH_YOUR_APP_ID")
          .connect(new DittoConfig.Connect.Server("wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL"))
          .build();

      Ditto ditto = DittoFactory.create(config);

      // Set up authentication with playground token
      ditto.getAuth().login(
          "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
          DittoAuthenticationProvider.playground()
      ).thenAccept(clientInfo -> {
          // Disable DQL strict mode so that collection definitions are not required in DQL queries
          ditto.getStore().execute("ALTER SYSTEM SET DQL_STRICT_MODE = false");

          ditto.startSync();
      }).exceptionally(error -> {
          // Handle authentication error
          return null;
      });
  } catch (DittoError e) {
      // Handle error in Ditto initialization
  }
  ```

  ```csharp C# theme={null}
  var identity = DittoIdentity.OnlinePlayground(
      appId, 
      playgroundToken, 
      false, // This is required to be set to false to use the correct URLs
      authUrl);

  ditto = new Ditto(identity, tempDir);

  ditto.UpdateTransportConfig(config =>
  {
      // Set the Ditto Websocket URL
      config.Connect.WebSocketUrls.Add("wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL");
  });

  // Disable DQL strict mode so that collection definitions are not required in DQL queries
  await ditto.Store.ExecuteAsync("ALTER SYSTEM SET DQL_STRICT_MODE = false");

  ditto.StartSync();
  ```

  ```cpp C++ theme={null}

  const auto identity = ditto::Identity::OnlinePlayground(
      std::move(app_id),
      std::move(online_playground_token),
      enable_cloud_sync,                  // This is required to be set to false to use the correct URLs
      std::move(custom_url)
  );

  ditto->update_transport_config([&](ditto::TransportConfig &config) {
      config.enable_all_peer_to_peer();
      config.connect.websocket_urls.insert(websocket_url);
  });
  // Required for compatibility with DQL.
  ditto->disable_sync_with_v3();

  // Disable DQL strict mode so that collection definitions are not required in DQL queries
  ditto->get_store().execute("ALTER SYSTEM SET DQL_STRICT_MODE = false");

  ditto->start_sync();
  ```

  ```rust Rust theme={null}
  use dittolive_ditto::prelude::*;
  use std::time::Duration;

  // Initialize with DittoConfig using database_id (was app_id in v4)
  let database_id = DatabaseId::from_str("REPLACE_ME_WITH_YOUR_DATABASE_ID")?;
  let config = DittoConfig::new(
      database_id.clone(),
      DittoConnect::Server {
          url: format!("https://{}.cloud.ditto.live", database_id)
      }
  );

  let ditto = Ditto::open(config)?;

  // Set up authentication expiration handler
  ditto.auth().set_expiration_handler(|ditto, seconds_remaining| {
      ditto.auth().login(
          "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
          Authenticator::development_provider(),
          |result| {
              if let Err(e) = result {
                  eprintln!("Auth error: {}", e);
              }
          }
      );
  });

  // Configure transport (optional)
  ditto.set_transport_config({
      let mut config = TransportConfig::new();
      config
          .connect
          .websocket_urls
          .insert(format!("wss://{}.cloud.ditto.live", database_id));
      config
  });

  // Start sync (was ditto.start_sync() in v4)
  ditto.sync().start()?;
  ```

  ```go Go theme={null}
  const endpoint = "REPLACE_ME_WITH_YOUR_URL"
  const id       = "REPLACE_ME_WITH_YOUR_DATABASE_ID"
  const token    = "REPLACE_ME_WITH_YOUR_DEVELOPMENT_TOKEN"

  config := ditto.DefaultDittoConfig().
      WithDatabaseID(id).
      WithConnect(&ditto.DittoConfigConnectServer{URL: endpoint})

  dit, err := ditto.Open(config)
  if err != nil {
      log.Fatalf("error: failed to open Ditto: %v", err)
  }
  defer dit.Close()

  // Set up authentication expiration handler (required for server connections)
  dit.Auth().SetExpirationHandler(
      func(d *ditto.Ditto, timeUntilExpiration time.Duration) {
          _, err := d.Auth().Login(token, ditto.DevelopmentAuthenticationProvider())
          if err != nil {
              log.Errorf("Authentication failed: %v", err)
          } else {
              log.Printf("Authentication succeeded")
          }
      })

  if err := dit.Sync().Start(); err != nil {
      log.Errorf("error: failed to start sync: %v", err)
  }
  ```
</CodeGroup>
