Skip to content

Client

Implementation of the StreamPipes client. The client is designed as the central point of interaction with the StreamPipes API and provides all functionalities to communicate with the API.

StreamPipesClient(client_config, logging_level=logging.INFO)

The client to connect to StreamPipes.

This is the central point of contact with StreamPipes and provides all the functionalities to interact with it.

The client provides so-called "endpoints" each of which refers to an endpoint of the StreamPipes API, e.g. .dataLakeMeasureApi. An endpoint provides the actual methods to interact with StreamPipes API.

PARAMETER DESCRIPTION
client_config

Configures the client to connect properly to the StreamPipes instance.

TYPE: StreamPipesClientConfig

logging_level

Influences the log messages emitted by the StreamPipesClient

TYPE: Optional[int] DEFAULT: INFO

ATTRIBUTE DESCRIPTION
dataLakeMeasureApi

Instance of the data lake measure endpoint

TYPE: DataLakeMeasureEndpoint

dataStreamApi

Instance of the data stream endpoint

TYPE: DataStreamEndpoint

RAISES DESCRIPTION
AttributeError:

In case an invalid configuration of the StreamPipesClientConfig is passed

Examples:

from streampipes.client import StreamPipesClient
from streampipes.client.config import StreamPipesClientConfig
from streampipes.client.credential_provider import StreamPipesApiKeyCredentials
client_config = StreamPipesClientConfig(
    credential_provider=StreamPipesApiKeyCredentials(
         username="test-user",
         api_key="api-key"
     ),
     host_address="localhost",
     https_disabled=True
)

The following way of instantiating a client instance is intended to be consistent with the StreamPipes Java client.

client = StreamPipesClient.create(client_config=client_config)

If you prefer a more pythonic way, you can simply write:

client = StreamPipesClient(client_config=client_config)

To interact with an endpoint:

data_lake_measures = client.dataLakeMeasureApi.all()

To inspect returned data as a pandas dataframe:

data_lake_measures.to_pandas()
#
#     measure_name timestamp_field  ... pipeline_is_running num_event_properties
# 0           test   s0::timestamp  ...               False                    2
# [1 rows x 6 columns]

base_api_path: str property

Constructs the basic API URL from the given client_config.

RETURNS DESCRIPTION
base_api_path

basic API path of the connected StreamPipes instance

TYPE: str

http_headers: Dict[str, str] property

Returns the HTTP headers used for all requests.

The HTTP headers are composed of the authentication headers supplied by the credential provider and additional required headers (currently this is only the application header).

RETURNS DESCRIPTION
http_headers

header information for HTTP requests as string key-value pairs.

TYPE: Dict[str, str]

create(client_config, logging_level=logging.INFO) classmethod

Returns an instance of the StreamPipesPythonClient.

Provides consistency to the StreamPipes Java client.

PARAMETER DESCRIPTION
client_config

Configures the client to connect properly to the StreamPipes instance.

TYPE: StreamPipesClientConfig

logging_level

Influences the log messages emitted by the StreamPipesClient.

TYPE: int DEFAULT: INFO

RETURNS DESCRIPTION
StreamPipesClient

describe()

Prints a short description of the connected StreamPipes instance and the available resources to the console.

RETURNS DESCRIPTION
None

Examples:

client.describe()
Output:
Hi there!
You are connected to a StreamPipes instance running at http://localhost:80.
The following StreamPipes resources are available with this client:
6x DataStreams
1x DataLakeMeasures