API Endpoint for Odoo Company Data Extraction (JSON or Excel) - n8n Workflow

Use this powerful n8n workflow template to create a secure API endpoint for fetching Odoo company data, validating inputs, and conditionally exporting results as JSON or Excel (.xlsx).

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Odoo administrators needing a quick way to export filtered company data.

  • Integration developers requiring a flexible API service for Odoo records.

  • Business Intelligence (BI) teams needing periodic data dumps in Excel format.

  • Users looking for advanced examples of conditional logic within an n8n workflow.

Overview

This sophisticated n8n workflow establishes a custom API endpoint (/api/v1/get-companies) designed to interface directly with your Odoo instance. It solves the common problem of needing dynamic data extraction where the output format (JSON for system integration or Excel for human review/reporting) must be selectable by the requester.

The core of this n8n automation is its ability to handle required input validation and execute conditional flow control. By utilizing this reusable n8n templates structure, you can ensure that only valid requests proceed to query Odoo, saving resources and ensuring data integrity. This specific n8n workflow demonstrates best practices for building robust internal data services using the n8n platform.

How it Works

The entire process begins with the designated n8n trigger, which activates upon an incoming HTTP request.


  1. Trigger Activation: The Receive Company Request n8n node acts as the entry point, listening on the specified path for incoming queries.

  2. Input Validation and Filtering: The Prepare Dynamic Filter Function n8n node immediately processes the request query parameters. Crucially, it validates that the name parameter is present (used for searching companies). It dynamically prepares the filter criteria for Odoo and determines the required responseformat (defaulting to JSON).

  3. Data Retrieval: The Fetch Companies from Odoo Odoo n8n node executes the search against the res.company resource using the prepared filters, retrieving all matching records.

  4. Output Preparation: The Prepare Output Data Function n8n node structures the results, handles null outcomes by returning a failure message, and adds a generation timestamp to the data items.

  5. Conditional Routing: The Check If Excel Required If n8n node examines the responseformat variable set earlier.

If the format is 'excel', the workflow proceeds down the true branch.
If the format is anything else (typically JSON), it proceeds down the false branch to Respond with JSON.

  1. Excel Conversion (True Path): If Excel is requested, the data items are passed to the Convert to Excel n8n node, which generates a binary XLSX file. The workflow then uses the Respond with File n8n node to send this binary output back to the requester as a downloadable file.

  2. JSON Response (False Path): If JSON is requested, the workflow simply uses the Respond with JSON n8n node to return the structured list of company data items.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON code and paste it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Webhook Setup: The Receive Company Request n8n trigger is already configured with the path /api/v1/get-companies and is set to return the data immediately.

  3. Odoo Credentials: Locate the Fetch Companies from Odoo n8n node. You must set up or link existing Odoo API credentials (including your Odoo URL, API key/password, and database name) to enable the connection. If you plan to use this n8n workflow on a production system, ensure these credentials have appropriate read permissions.

  4. Customization (Optional): Review the fieldsList in the Odoo n8n node settings to add or remove specific company fields (e.g., VAT number, primary address) relevant to your reports.

  5. Testing: Execute the n8n workflow manually or via an HTTP client (like Postman) using queries such as YOURN8NURL/api/v1/get-companies?name=ExampleCorp&response_format=excel to confirm functionality.

Node Details

Receive Company Request (Webhook n8n trigger):
Function: Serves as the public API entry point for the n8n workflow.
Key Configuration: Path is set to /api/v1/get-companies. Response mode is configured to await a specific response node.

Prepare Dynamic Filter (Function n8n node):
Function: Validates the required name query parameter and generates the necessary Odoo filter array, ensuring robust input handling before database interaction.
Key Configuration: Contains JavaScript logic to check for missing 'name' and define the responseformat variable.

Fetch Companies from Odoo (Odoo n8n node):
Function: Communicates with the Odoo API to retrieve records from the res.company resource based on the dynamic filter created by the previous n8n node.
Key Configuration: Operation set to getAll, Resource set to custom (res.company), and filters use an expression linking to the data from the Prepare Dynamic Filter n8n node.

Check If Excel Required (If n8n node):
Function: Manages the flow control, directing the data based on the user's requested output format.
Key Configuration: Checks if {{ $('Prepare Dynamic Filter').item.json.response
format }} equals 'excel'.

Convert to Excel (Convert to File n8n node):
Function: Converts the incoming JSON data structure into a binary Microsoft Excel (XLSX) file.

Respond with File/Respond with JSON (Respond to Webhook n8n nodes):
Function: Handles sending the final HTTP response. One n8n node handles binary file responses (Excel), and the other handles structured JSON responses.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by
V3 Code Studio
V3 Code Studio

🚀 AI & Automation Expert | n8n Creator | Workflow Specialist | Automation Specialist | V3 Code Studio I build smart automation workflows with n8n to help businesses streamline operations, save time, and increase productivity. Passionate about no-code/low-code automation and AI-driven solutions that make processes efficient, scalable, and growth-oriented.

Featured*