Arjun Baidya’s Post

View profile for Arjun Baidya

Senior Odoo Full-Stack Developer | Helping Companies Automate HR & Business Operations with ERP | Expert in Odoo v13–v19 • Cloud (AWS/Odoo.sh) • Python • React • OWL.js

Clean REST API in Odoo: How I Build Secure & Scalable Endpoints While Odoo traditionally uses JSON-RPC, modern integrations often require REST API endpoints—especially for mobile apps, external platforms, or microservices. Here’s how I built a clean, secure REST API in Odoo using controllers 👇 🛠 Sample REST Endpoint (Controller-Based) from odoo import http from odoo.http import request, Response import json class OrderAPIController(http.Controller): @http.route('/api/orders', type='json', auth='api_key', methods=['GET'], csrf=False) def get_orders(self, **kwargs): orders = request.env['sale.order'].sudo().search_read( [], ['name', 'partner_id', 'amount_total', 'state'] ) return {"status": "success", "data": orders} @http.route('/api/order/create', type='json', auth='api_key', methods=['POST'], csrf=False) def create_order(self, **data): try: order = request.env['sale.order'].sudo().create({ 'partner_id': data.get('partner_id'), 'date_order': data.get('date_order'), }) return {"status": "created", "order_id": order.id} except Exception as e: return Response(json.dumps({"error": str(e)}), status=400, mimetype='application/json') ✅ Best Practices I Follow ✔ Use auth='api_key' or OAuth—never auth='public' for sensitive data ✔ Use POST for create/update, GET for retrieving data ✔ Filter fields with search_read to avoid large payloads ✔ Always wrap responses in JSON format (status + data/error) ✔ Log failed API calls for debugging & auditing 🚀 Real Use Case from My Work I built a REST API to sync customer and order data between Odoo & a Shopify-based online store. Result: Orders synced in under 5 seconds Inventory auto-updated Manual data entry removed completely I’m growing my network with businesses who need: ✔ Custom REST API development in Odoo ✔ System integration & process automation ✔ Remote or hybrid Odoo technical expertise If your business needs clean, secure ERP APIs — happy to connect and collaborate. #OdooDeveloper #OdooConsultant #ERPImplementation #ERPOptimization #BusinessAutomation #DigitalTransformation #AustralianBusiness #SydneyTech #MelbourneTech #BrisbaneBusiness #OdooPerformance #OdooExpert #PostgreSQL #PythonDeveloper #RemoteDeveloper #HiringInAustralia #TechConsultant

To view or add a comment, sign in

Explore content categories