Consume data
This page explains how to consume data from GlassFlow pipelines.
Ways to consume data from GlassFlow
Consuming data is retrieving transformed data from a data pipeline in GlassFlow. You use built in integrations to consume data or write code in Python to implement a new custom integration.
Consuming data using integrations
Visit Integrations page for more information.
Consuming data via Python SDK
The Python SDK provides a programmatic way to interact with GlassFlow pipelines to produce or consume data continuously. Using the SDK you create a custom connector for any data sink in Python.
Prerequisites
You created a Pipeline.
You have the pipeline credentials such as PIPELINE_ID and PIPELINE_ACCESS_TOKEN.
Install GlassFlow Python SDK
Install a GlassFlow SDK using the pip
command in a terminal.
Set environment variables
Set environment variables with your actual GlassFlow pipeline credentials such as PIPELINE_ID
and PIPELINE_ACCESS_TOKEN:
Consume Transformed Data from the pipeline
Create a new Python script file called consumer.py
and insert the code below.
This script continuously checks for newly transformed data from the pipeline and consumes it as needed. The main GlassFlow SDK usage revolves around creating a GlassFlow pipeline client instance to interact with the GlassFlow platform and consume data from the data pipeline.
Initializes a GlassFlow client to establish a connection with the GlassFlow platform for a specific pipeline. The SDK automatically reads the needed parameters (
pipeline_id
andpipeline_access_token)
from the environment variables. Alternatively, you can also pass them as parameters when creating the client:
Without the pipeline credentials params:
With the pipeline credentials params:
Consumes the transformed data from the pipeline. It returns a response object containing the consumed event data.
You receive a ConsumeEventResponse
object in response
. This response object contains:
status_code
: Thestatus_code
attribute holds the HTTP status code of the response.json()
: A helper function to get the transformed event as a JSON object.
Refer to Python SDK documentation for more details.
Run the script
You will get output similar to the following:
Next
See tutorials for complex scenarios.
Last updated