Ingest from the Cloud SDK

Ingestion with the Cloud SDK

The primary way of ingesting arbitrary data that is not via the Formant agent is with the Cloud SDK, a lightweight Python module which can interact with the Formant ingestion API directly. It can be installed with pip3 install formant.

Why use the Cloud SDK?

There are many good reasons to use the Formant agent for most of your ingested data: the agent provides buffering logic, has many automatic ingestion capabilities, has ROS capabilities, integrates with several adapters, and provides default telemetry streams.

Still, sometimes you may want to ingest directly without requiring an agent. The ingest method of the Formant Cloud SDK is a good option in those situations.

See the full guide on Ingesting telemetry without an agent.

Example of ingestion with the Formant Cloud SDK

from formant.sdk.cloud.v1 import Client as FormantClient


if __name__ == "__main__":
    # to authenticate set FORMANT_EMAIL and FORMANT_PASSWORD
    # environment variables for an existing service account
    # NOTE: the account must have administrator access to ingest data
    fclient = FormantClient()

    device_id = "572f5ff3-63e9-4687-b242-c0d8a4891d80"
    timestamp = 1609804800000
    tags = {"location": "sf"}

        # Ingest numeric data
    ingest_result = fclient.ingest(
        {
            "items": [
                {
                    "deviceId": device_id,
                    "name": "engine_temp",
                    "type": "numeric",
                    "tags": tags,
                    "points": [[timestamp, 100]],
                }
            ]
        }
    )

Did this page help you?