Blueprints

Extract field from JSON object in API call and pass to subsequent task

About this blueprint

API Getting Started Git Outputs

A common use-case may be to retrieve a specific field from a JSON payload in an API request and use that further downstream.

In this simple example we will query the number of stars for a given Github repo and then output it as a message.

yaml
id: stars
namespace: blueprints

inputs:
  - id: repo
    type: STRING
    defaults: kestra-io/kestra

tasks:
  - id: api_query
    type: io.kestra.plugin.core.http.Request
    contentType: application/json
    headers:
      User-Agent: kestra
    uri: "https://api.github.com/repos/{{inputs.repo}}"
    
  - id: get_stars
    type: io.kestra.plugin.core.log.Log
    message: ✨✨✨ Total GitHub stars {{json(outputs.api_query.body).stargazers_count }} ✨✨✨

Request

Log

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra