New to Kestra?
Use blueprints to kickstart your first workflows.
Call any REST API, capture the JSON response, and insert it as a document into MongoDB with Kestra. Parameterized, retryable, and fully declarative in YAML.
id: load-pokemon
namespace: company.team
inputs:
- id: pokemon
type: STRING
defaults: psyduck
tasks:
- id: fetch_pokemon
type: io.kestra.plugin.core.http.Request
uri: https://pokeapi.co/api/v2/pokemon/{{ inputs.pokemon }}
method: GET
- id: load
type: io.kestra.plugin.mongodb.InsertOne
connection:
uri: mongodb://host.docker.internal:27017/
database: local
collection: pokemon
document: "{{ outputs.fetch_pokemon.body }}"
This flow extracts JSON data from a REST API and loads it as a document into MongoDB. It uses the PokeAPI as a concrete example, fetching a Pokemon by name and inserting the raw JSON response into a collection. The pattern solves a common ingestion need: pulling semi-structured data from an HTTP endpoint and persisting it into a document store without writing a custom script or standing up a separate ETL service. Because the Pokemon name is a runtime input, the same flow can target any record on demand.
fetch_pokemon task (io.kestra.plugin.core.http.Request) issues a GET request to https://pokeapi.co/api/v2/pokemon/{{ inputs.pokemon }}, where the pokemon input defaults to psyduck but can be overridden at execution time.load task (io.kestra.plugin.mongodb.InsertOne) connects to MongoDB via the connection.uri property and inserts {{ outputs.fetch_pokemon.body }} into the pokemon collection of the local database.pokemon STRING input.A standalone script or a cron job can call an API and write to MongoDB, but it cannot give you event-driven execution, automatic retries on transient HTTP or database failures, execution-level lineage between the fetch and load steps, or a declarative YAML definition that lives in version control. Kestra wires the HTTP response directly into the MongoDB insert through {{ outputs.fetch_pokemon.body }}, so the data contract between tasks is explicit. MongoDB has no native scheduler or pipeline engine of its own, so Kestra fills the gap that the database cannot: orchestrating when and how data arrives, observing every run, and replaying failures.
connection.uri (the example uses mongodb://host.docker.internal:27017/).This flow references no secrets. The MongoDB connection is supplied inline through connection.uri. For production, move the URI into a secret and reference it with {{ secret('MONGODB_URI') }}.
connection.uri value.pokemon input.pokemon collection in the local database to see the inserted document.InsertOne with a bulk insert or upsert to handle batches.Schedule or webhook trigger to run the flow automatically.