Instantiate a client object (C#)
All Data API interactions through a client start with a DataAPIClient object.
Once you have a DataAPIClient object, you can connect to a database and the perform CRUD operations on your data.
Creating a client object is an essential component of Data API client scripts. For more information, see Get started with the Data API (C#).
For more information about the Data API client hierarchy, see Python client internals, TypeScript client internals, Go client internals, Java client internals, and C# client internals.
Result
Returns a DataAPIClient object that you can use to interact with the Data API.
Parameters
| Name | Type | Summary |
|---|---|---|
|
|
Optional.
An application token for a database, in the form of The token should have sufficient permissions to perform the desired operations.
|
|
A class wrapping the advanced configuration of the client, such as |
Examples
The following examples demonstrate how to instantiate a client.
Instantiate a client
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
namespace Examples;
public class Program
{
static void Main()
{
var client = new DataAPIClient();
}
}
Instantiate a client and pass a token
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
namespace Examples;
public class Program
{
static void Main()
{
var client = new DataAPIClient("APPLICATION_TOKEN");
}
}
Instantiate a client and specify options
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
namespace Examples;
public class Program
{
static void Main()
{
var options = new CommandOptions()
{
TimeoutOptions = new TimeoutOptions()
{
ConnectionTimeout = TimeSpan.FromMilliseconds(3000),
RequestTimeout = TimeSpan.FromMilliseconds(9000),
},
};
var client = new DataAPIClient(options);
}
}
Client reference
For more information, see the client reference.