ReferenceDriverHTTPRead Task

HTTP Read Task

Learn how to acquire data from HTTP endpoints with Synnax.

For task lifecycle management, see the Task Basics page.

Task Configuration Reference

ParameterTypeRequiredDefaultDescription
namestringYes-Human-readable task name
devicestringYes-Key of the HTTP server device
ratenumberYes-Polling rate (Hz)
data_savingbooleanNotrueEnable permanent storage in Synnax
auto_startbooleanNofalseAutomatically start task after configuration or on Driver bootup
endpointsarrayYes-List of endpoint configurations

Endpoint Configuration Reference

Each endpoint defines an HTTP request to poll and a set of fields to extract from its JSON response.

ParameterTypeRequiredDefaultDescription
methodstringNo"GET"HTTP method
pathstringYes-URL path relative to the device base URL (e.g., /api/v1/data)
headersobjectNo-Additional request headers
query_paramsobjectNo-Query parameters
bodystringNo-Request body (for POST or other methods that accept a body)
fieldsarrayYes-Fields to extract from the response

Field Extraction Reference

Fields define how to extract values from a JSON response body using JSON Pointers (RFC 6901). Each field maps a location in the response to a Synnax channel.

For example, given this response:

{ "temperature": 23.5, "sensors": { "pressure": 101.3 } }

A pointer of /temperature extracts 23.5, and /sensors/pressure extracts 101.3.

ParameterTypeRequiredDefaultDescription
pointerstringYes-JSON Pointer path to the value (e.g., /temperature)
channelnumberYes-Synnax channel key to write the extracted value to
data_typestringNo"float64"Data type of the channel
namestringNo-Human-readable name for the field
enabledbooleanNotrueWhether this field is active
timestamp_formatstringNo-Timestamp format (required when the channel data type is TIMESTAMP)
enum_valuesarrayNo-String-to-number mapping for enum fields (e.g., [{"label": "OFF", "value": 0}, {"label": "ON", "value": 1}])

Enum Values

When the HTTP response contains string values that represent discrete states, use enum_values to map them to numbers. The driver converts matching strings to their numeric equivalents before writing to the channel.

http.ReadField(
    pointer="/status",
    channel=status_ch.key,
    data_type="float64",
    enum_values=[{"label": "OFF", "value": 0}, {"label": "ON", "value": 1}, {"label": "ERROR", "value": 2}],
)

If the response value does not match any key in the map, the driver reports an error.

Timestamp Handling

By default, the driver automatically generates timestamps for each poll cycle using software timing. If your HTTP response includes a timestamp field, you can extract it directly by setting timestamp_format on a field whose channel data type is TIMESTAMP.

Supported Timestamp Formats

FormatDescriptionExample
iso8601ISO 8601 date-time string"2024-01-15T10:30:00.000Z"
unix_secSeconds since Unix epoch1705312200
unix_msMilliseconds since Unix epoch1705312200000
unix_usMicroseconds since Unix epoch1705312200000000
unix_nsNanoseconds since Unix epoch1705312200000000000

Software vs. Hardware Timing

Software timing (default): The Driver generates a timestamp at each poll cycle. All fields that share the same index channel are written atomically. No timestamp_format is needed on any field.

Hardware timing: If your response includes a timestamp, create a TIMESTAMP channel as the index and add a field that extracts it with a timestamp_format. Other fields using that index channel will be grouped with the extracted timestamp.

How-To

Console

Python