| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 3648 |
| Technical Name |
api_gateway |
| License | LGPL-3 |
| Website | mailto:piyush23321@gmail.com |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 3648 |
| Technical Name |
api_gateway |
| License | LGPL-3 |
| Website | mailto:piyush23321@gmail.com |
API Gateway Pro
Transform your Odoo into a secure, production-ready REST API server. No Redis, no middleware, no extra infrastructure - powered entirely by native Odoo and PostgreSQL.
Everything in one module
A complete API infrastructure layer - from authentication to analytics - built natively inside Odoo.
Real-Time Analytics Dashboard
A fully custom OWL component with 9 live ApexCharts, 15+ KPIs, WebSocket push, animated counters, sound alerts, and a live fault feed - all inside Odoo.
Primary KPI Cards
Animated counter cards at the top of the dashboard. All values update smoothly with cubic easing on every data refresh.
Live Push & Controls
- ✓ WebSocket mode - Odoo bus pushes telemetry instantly. No polling needed. Heartbeat RPS counter increments in real time.
- ✓ Polling fallback - Choose 5s, 10s, 30s, or 60s intervals if WebSocket is unavailable.
- ✓ Manual mode - Pause all updates and refresh on demand.
- ✓ Sound alerts - Web Audio API plays a tone on 5xx errors. Toggle on/off from the header.
- ✓ Toast notifications - Slide-in alerts when error rate exceeds 10% or a 5xx is detected.
- ✓ Light / Dark / Auto theme - All 9 charts rerender in the selected theme instantly.
- ✓ Time filters - 24H, 30D, 1Y range selector updates all charts simultaneously.
- ✓ User & status filter - Drill down by specific API key user or status code class.
Live Fault Feed
Bottom section of the dashboard - a live updating table of all failed requests (4xx/5xx). Click Inspect on any row to open the full log record in a popup. Export to CSV with one click.
Universal REST API Engine
One endpoint pattern works for every Odoo model instantly - no custom routes, no extra code, no scaffolding required.
Endpoint Pattern
Smart Query Parameters
Complete Endpoint Reference
| Method | Endpoint | Action | Notes |
|---|---|---|---|
| GET | /api/v1/<model> | search_read() | Supports domain, fields, limit, offset, order |
| GET | /api/v1/<model>/<id> | search_read() | Returns single record by ID |
| POST | /api/v1/<model> | create() | JSON body → new record. Returns created ID. |
| PUT | /api/v1/<model>/<id> | write() | Full or partial update |
| PATCH | /api/v1/<model>/<id> | write() | Alias for PUT |
| DELETE | /api/v1/<model>/<id> | unlink() | Permanently deletes the record |
| GET | /api/v1/ping | Health check | Returns pong + user + timestamp |
OAuth2 Authentication - JWT
Full OAuth2 Client Credentials flow with signed JWT tokens, scope-based access control, token revocation, and automatic cleanup. Built for machine-to-machine (M2M) integrations.
Authentication Flow
gw_xxxxxxxxxxxx) and 32-char secret shown once./api/oauth/token with grant_type=client_credentials.Authorization: Bearer <token> on every API call. Scopes enforced per HTTP method.
/api/oauth/clients.Token Request & Response
Odoo API Key Authentication
Built on top of Odoo's native res.users.apikeys infrastructure.
Zero extra setup - keys already exist in every Odoo instance.
- ✓ Native integration - uses the same keys Odoo already generates in user preferences. No new key storage.
- ✓ RAM-cached validation - token lookup happens entirely in-memory via
@tools.ormcache. Zero database hits per request during validation. - ✓ 600,000 PBKDF2-SHA512 rounds - constant-time passlib verification prevents timing attacks.
- ✓ API Profiles - attach a custom profile (rate limit, IP whitelist) to any Odoo user. All their API keys inherit the profile's rules automatically.
- ✓ Key expiration - optional expiry date per key. Expired keys return 401.
- ✓ Cache invalidation - profile changes flush the registry cache instantly so policy updates take effect immediately.
Atomic Rate Limiting - Zero Redis
Enterprise-grade rate limiting powered purely by a single atomic PostgreSQL UPSERT. No Redis, no Celery, no distributed lock managers needed.
How it works
- ✓ Atomic UPSERT - single
INSERT ... ON CONFLICT DO UPDATESQL statement. Increments the counter and returns the new value in one round-trip. - ✓ Multi-worker safe - works across all Odoo worker processes without any inter-process communication.
- ✓ Three time windows - per-minute, per-hour, per-day. Each tracked independently.
- ✓ Per-user limits - API Profiles set individual rate limits per user or OAuth2 client.
- ✓ Global fallback - a global limit applies to any user without a custom profile.
- ✓ 429 response - rate-limited requests return
HTTP 429 Too Many Requestswith a JSON error body. - ✓ Live throttle view - see active rate limit windows per user in real time via API Gateway → Active Throttles.
IP Whitelisting
Restrict API access to trusted IP addresses at both the profile level and per OAuth2 client. Requests from unlisted IPs are rejected immediately.
- ✓ Per-user configuration
- ✓ Supports multiple IPs (newline-separated)
- ✓ 403 returned for non-whitelisted IPs
/api/oauth/token) and on every API call using that token.
- ✓ Per-client configuration
- ✓ Checked at token request AND token use
- ✓ Combines with scope enforcement
Outbound Webhooks
Push real-time events from any Odoo model to any external URL - automatically, asynchronously, and reliably. No external queue broker required.
Configuration
- ✓ Any Odoo model - bind a webhook to res.partner, sale.order, stock.picking, or any custom model.
- ✓ Three triggers - fire on
create,write, orunlink. - ✓ Custom HTTP headers - add any headers directly from the UI (Authorization, X-API-Key, X-Signature, etc.).
- ✓ Async queue - webhook jobs are queued immediately without blocking the user's browser or the ORM transaction.
- ✓ Cron processing - background cron runs every minute, processes up to 50 pending jobs, with a 10-second timeout per call.
- ✓ Retry with backoff - failed jobs are retried automatically. Error messages stored for debugging.
- ✓ Auto-vacuum - old processed jobs cleaned up after 30 days automatically.
Payload Structure
Interactive API Documentation
A beautiful Scalar UI portal embedded directly in Odoo at /api/docs -
backed by a dynamic OpenAPI 3.0 spec. No external hosting, no Swagger UI.
GET /api/openapi.json returns a fully generated OpenAPI
3.0 spec with all endpoints, parameters, request bodies, and security
schemes. CORS enabled for external tools.
Traffic Logs & Telemetry
Every API request can be logged with configurable detail levels. Bearer tokens are auto-redacted. Full payload capture available for debugging.
Three Log Levels
- ✓ Auto-redaction - Bearer tokens in Authorization headers stored as
Bearer **********. Secrets never leak into logs. - ✓ Error traceback - full Python traceback stored on 5xx errors for debugging.
- ✓ Auto-vacuum - logs older than the configured retention period (default 30 days) deleted automatically by cron.
- ✓ Group by - group log records by date, user, status code, or endpoint.
- ✓ Smart buttons - from an API Profile, click through directly to that user's traffic logs.
Light / Dark / Auto Theme
The dashboard ships with a fully themeable design system. Three modes, all 9 charts rerender in real time, settings persist per browser.
prefers-color-scheme media query. Switches automatically when OS theme changes. No manual toggle needed.
Global Settings
All global policies configured in one place under Settings → API Gateway. No file editing required.
| Setting | Default | Description |
|---|---|---|
| Default GET Limit | 80 | Max records returned if client doesn't specify |
| Global Rate Limit | 60 | Fallback requests per window for users without a profile |
| Rate Window | minute | minute / hour / day |
| Log Level | errors | errors / metadata / payloads |
| Log Retention | 30 days | Days before logs are auto-deleted |
| JWT Secret | auto-gen | HMAC-SHA256 signing key for OAuth2 tokens |
API Gateway Pro vs Alternatives
See how API Gateway Pro compares to typical approaches for exposing Odoo data to external systems.
| Feature | API Gateway Pro ⚡ | Custom Odoo Routes | Odoo Default XML-RPC |
|---|---|---|---|
| Works on any model instantly | ✓ Yes | ✗ Manual per-model | ~ Limited |
| OAuth2 JWT Authentication | ✓ Yes | ✗ Build yourself | ✗ No |
| Rate Limiting (no Redis) | ✓ Yes | ✗ Build yourself | ✗ No |
| IP Whitelisting | ✓ Yes | ✗ Build yourself | ✗ No |
| Outbound Webhooks | ✓ Yes | ✗ Build yourself | ✗ No |
| Real-Time Analytics Dashboard | ✓ Yes | ✗ No | ✗ No |
| Interactive API Docs (OpenAPI) | ✓ Yes | ✗ No | ✗ No |
| RESTful JSON responses | ✓ Yes | ~ Manual | ✗ XML-RPC only |
| Native ACL/Record Rule enforcement | ✓ Yes | ~ Manual | ✓ Yes |
| Zero extra infrastructure | ✓ Yes | ✓ Yes | ✓ Yes |
Automatic Maintenance Crons
Five background cron jobs keep your API Gateway clean and efficient with zero manual intervention.
Module Menu Structure
All features accessible from a single top-level menu: API Gateway.
Compatibility
hmac, hashlib, json, and base64
modules for JWT encoding. No PyJWT, no Redis, no Celery.
Please log in to comment on this module