Skip to content

API Reference

To power our decoupled Nuxt 3 frontend, we developed several custom, whitelisted Frappe API endpoints located in commercial_garage/api.py. These endpoints bypass Frappe's standard rendering pipeline to return lightweight, typed JSON responses tailored for the Vue frontend.

Core Endpoints

1. get_currency_settings

  • Method: GET
  • Endpoint: /api/method/commercial_garage.api.get_currency_settings
  • Description: Returns a consolidated payload of the active Base Currency, a list of enabled currencies (with cached exchange rates), and a list of disabled "available" currencies.
  • Optimizations: Avoids external HTTP calls. Reads exchange rates directly from Frappe's Currency Exchange doctype using an indexed DB lookup.

2. sync_exchange_rates

  • Method: POST
  • Endpoint: /api/method/commercial_garage.api.sync_exchange_rates
  • Description: Dispatches a background job to fetch real-time exchange rates from the Frankfurter API and insert them into the Currency Exchange doctype.
  • Optimizations: Uses frappe.enqueue with a short timeout to prevent HTTP connection hanging on the frontend. The Nuxt client receives a fast 200 OK while Frappe processes the rates asynchronously.

3. set_base_currency

  • Method: POST
  • Endpoint: /api/method/commercial_garage.api.set_base_currency
  • Parameters: currency_code (String)
  • Description: Safely mutates the Global Defaults doctype to update the company's base currency. Checks for existing accounting entries to prevent data corruption.

4. enable_currency

  • Method: POST
  • Endpoint: /api/method/commercial_garage.api.enable_currency
  • Parameters: currency_code (String)
  • Description: Updates the Currency doctype record, setting enabled = 1. This immediately exposes the currency to the frontend grid and includes it in the nightly exchange rate sync job.

Background Services & Real-time Integration

In addition to static REST APIs, we have integrated with Frappe's underlying event loops:

  • WebSockets: Our Nuxt application connects to /socket.io and listens to room-based Frappe events (e.g., frappe:workflow_update).
  • Scheduled Jobs: Native Frappe scheduler events (like daily) are utilized to keep local database copies of heavy data (like exchange rates) fresh, keeping the REST APIs sub-500ms.

Edge Home Solutions - Professional · Reliable · Trusted