New to Kestra?
Use blueprints to kickstart your first workflows.
Call a REST API in a Dockerized Python task, write the response to JSON, and load it into a MongoDB collection with Kestra in one declarative flow.
Pull a JSON payload from any REST API and land it in MongoDB without standing up custom glue code. This flow runs a Python script inside an isolated Docker container to call the GitHub API, captures the response as a JSON file, and bulk loads that document into a MongoDB collection. It is a ready made template for API to document store ingestion, web scraping pipelines, and keeping a NoSQL collection in sync with an upstream HTTP source.
generate_json task is an io.kestra.plugin.scripts.python.Script running on the io.kestra.plugin.scripts.runner.docker.Docker task runner. It installs the requests and kestra dependencies, calls https://api.github.com, and writes the parsed response to output.json declared in outputFiles. It also emits the raw data and HTTP status through Kestra.outputs().load_to_mongodb task is an io.kestra.plugin.mongodb.Load. It connects to MongoDB over the connection.uri, targets the local database and the github collection, and ingests the file referenced by {{ outputs.generate_json.outputFiles['output.json'] }}.data, status) you can branch on or reuse downstream.A raw Python cron job gives you no retries, no lineage, and no visibility when an API call fails. With Kestra you get event and schedule triggers, automatic retries, run history, and outputs passed cleanly between tasks, all declared in version controlled YAML. MongoDB itself has no scheduler or workflow engine, so Kestra fills the gap by deciding when ingestion runs, handling transient API failures, and wiring the Python extraction step to the MongoDB load step.
mongodb://host.docker.internal:27017/).This flow uses an open API and a local MongoDB URI, so no secret() values are referenced. If you point it at an authenticated API or a secured MongoDB, store credentials as secrets (for example {{ secret('MONGODB_URI') }}) and reference them in the connection.uri and script.
connection.uri.github collection in the local database to confirm the document was loaded.https://api.github.com for your own API endpoint and adjust the parsing logic.Schedule or webhook trigger to ingest on a cadence or on demand.database and collection, or template them from inputs.