Run Multiple Python Versions Side by Side in One Flow
Run the same script on Python 3.9 and Python 3.13 in one flow, each task pinned to its own container image, to evaluate a new runtime without touching production.
Parse a JSON REST API payload in Kestra and check whether a key exists using jq filters, the contains operator, and is not null Pebble expressions.
Working with REST APIs almost always means parsing JSON, and a recurring task is checking whether a specific key is present in the payload before you act on it. A classic example is pagination: a Twitter (X) API response includes a next_token field only when more pages remain, so your flow needs to detect that key reliably to decide whether to keep fetching. This blueprint shows three idiomatic ways to test for a key in a JSON object using Kestra expressions, so you can pick the style that reads best for your pipeline and branch on the result.
The flow defines a single json input of type JSON whose default payload mimics a paginated API response with a meta object containing next_token, oldest_id, newest_id, and result_count. Four tasks then evaluate that payload:
jq_filter is an io.kestra.plugin.core.log.Log task that runs the jq filter .meta | has("next_token") and logs whether the key exists.contains is an io.kestra.plugin.core.log.Log task that uses the Pebble contains operator: {{ inputs.json["meta"] contains "next_token" }}.contains_if_else_operator is another io.kestra.plugin.core.log.Log task that wraps contains in an {% if %} / {% else %} block to log an explicit true or false.is_not_null_operator is a final io.kestra.plugin.core.log.Log task that checks key presence before applying is not null. The presence check prevents a missing key from raising a rendering error. This value-based test is false when the key is absent or its value is null.jq filter, the contains operator, and an is not null test.jq filtering.A raw API or a cron scheduler can fetch JSON but cannot express conditional logic over the response. Kestra lets you parse payloads inline with declarative YAML, branch on the result, and chain follow-up tasks (loop until next_token is absent, fan out per record, or alert on missing fields). You gain event triggers, automatic retries on transient API failures, and full execution lineage over every parse, none of which the API itself provides.
This flow references no secrets. When you point it at a live API behind authentication, store the token as a secret (for example {{ secret('API_TOKEN') }}) rather than hardcoding it.
json payload to see all four tasks log true.next_token and re-run to see all four tasks log false.next_token to null to see the three presence checks log true and the value-based check log false.io.kestra.plugin.core.http.Request task that fetches a live API response.next_token is present.if condition to skip or trigger downstream tasks.