Fetch and Store External API Data as Local JSON File - n8n Workflow

Use this robust n8n workflow to fetch data from any external API (like TheCocktailDB) and efficiently store the JSON output as a local file using the Write Binary File n8n node. Perfect for local caching and development.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Users new to n8n looking to understand file handling.

  • Developers needing to test API integrations and locally cache results.

  • DevOps professionals running self-hosted n8n instances who require local disk operations.

  • Anyone building n8n templates that involve data persistence.

Overview

This versatile n8n workflow addresses the common requirement of fetching dynamic data from a third-party API and saving that information directly to the local disk where the n8n instance is running. While many n8n templates rely on cloud storage, saving files locally is crucial for development, quick testing, and accessing data within environments that restrict external connections.

The core value of this specific n8n workflow is showcasing the transition from a standard JSON data object (received from the HTTP Request n8n node) into a binary file format (using the Move Binary Data n8n node), which is necessary before the data can be written to disk. This process is fundamental for anyone looking to build complex file-processing n8n templates. The starting point is always the efficient n8n trigger, allowing for immediate execution and testing of the sequence.

How it Works

This powerful n8n workflow operates in four sequential stages:


  1. Initialization: The workflow starts with a Manual n8n Trigger, allowing the user to initiate the process immediately by clicking 'Execute Workflow'. This is ideal for testing and single runs.

  2. Data Retrieval: The 'HTTP Request' n8n node calls the external API (https://www.thecocktaildb.com/api/json/v1/1/random.php) to retrieve a JSON object containing information about a random cocktail. This results in standard JSON data ready for processing.

  3. Format Conversion: The 'Move Binary Data' n8n node receives the JSON data. Crucially, it is configured to operate in jsonToBinary mode. This step transforms the standard JSON item into a binary data stream, preparing it for file system writing. This transformation is necessary because the file writing n8n node requires binary input.

  4. Local Storage: The final 'Write Binary File' n8n node takes the newly created binary stream and saves it to the local file system, creating a file named cocktail.json. This completes the n8n workflow by persisting the fetched API data.

Installation Guide

To install this n8n workflow template:


  1. Copy the entire workflow JSON provided.

  2. Log into your n8n instance.

  3. In the Workflows section, click 'New' and then 'Import from JSON'. Paste the copied JSON data.

  4. No external credentials are required for the public API call used in this specific n8n template.

  5. Ensure your n8n instance has permissions to write files to the default directory (usually the working directory of the n8n server).

  6. Execute the workflow by clicking 'Execute Workflow' or testing the manual n8n trigger.

Node Details


  • On clicking 'execute' (Manual Trigger n8n Trigger):

- Function: Starts the execution flow instantly for testing purposes.
- Key Configuration: A simple manual n8n trigger, requiring no external setup.

  • HTTP Request (n8n Node):

- Function: Fetches real-time JSON data from TheCocktailDB API.
- Key Configuration: URL set to https://www.thecocktaildb.com/api/json/v1/1/random.php.

  • Move Binary Data (n8n Node):

- Function: Transforms the structured JSON data received from the API into a raw binary item, which is essential for file system operations.
- Key Configuration: Mode set to JSON to Binary.

  • Write Binary File (n8n Node):

- Function: Saves the binary data stream to the local disk of the n8n server.
- Key Configuration: File Name set to cocktail.json.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by
ghagrawal17
ghagrawal17

Featured*