Instantiate a client object (Python)
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 (Python).
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 an The token should have sufficient permissions to perform the desired operations.
|
|
|
Optional. Specify the environment this client will work in. Must be one of the values in Default: |
|
|
Optional. Attaches special identifying entries to the User-Agent header for all HTTP requests issued to the Data API. The full type of this parameter is |
|
|
Optional. A complete or partial specification of the APIOptions for the client. This allows you to customize the client interaction with the Data API. For example, you can use this parameter to change the timeout settings. |
Examples
The following examples demonstrate how to instantiate a client.
Instantiate a client
from astrapy import DataAPIClient
client = DataAPIClient()
Instantiate a client and pass a token
from astrapy import DataAPIClient
client = DataAPIClient("APPLICATION_TOKEN")
Instantiate a client and specify options
from astrapy import DataAPIClient
from astrapy.api_options import (
APIOptions,
SerdesOptions,
TimeoutOptions,
)
from astrapy.authentication import (
AWSEmbeddingHeadersProvider,
)
client = DataAPIClient(
api_options=APIOptions(
embedding_api_key=AWSEmbeddingHeadersProvider(
embedding_access_id="my-access-id",
embedding_secret_id="my-secret-id",
),
timeout_options=TimeoutOptions(
request_timeout_ms=15000,
general_method_timeout_ms=30000,
table_admin_timeout_ms=120000,
),
serdes_options=SerdesOptions(
custom_datatypes_in_reading=False,
use_decimals_in_collections=True,
),
)
)
Client reference
For more information, see the client reference.