Odoo Generic API
REST API access to any Odoo model, secured with JWT authentication. Useful for integrations with third-party or mobile applications.
Features
- Access any installed Odoo model via REST: no per-model configuration needed
- Full CRUD support: GET, POST, PUT, DELETE
- Secure JWT tokens with configurable expiration (PyJWT 2.x)
- Flexible field selection including nested relational fields (Many2one, Many2many, One2many)
- ORM-level filtering:
limit,offset,order,argsdomain - Compatible with Odoo
Authentication
Pass credentials as HTTP headers to obtain a token:
curl http://localhost:8069/auth \ -H 'user: admin' \ -H 'password: admin'
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Use the token in all subsequent requests via Authorization: Bearer <token>.
Tokens expire after 1 hour by default (configurable via EXPIRATION_IN_SECONDS env var).
Usage Examples
GET â fetch a record with specific fields:
curl --globoff 'http://localhost:8069/api/hr.employee/3?fields=["id","name","work_email"]' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{}'
POST â create a record:
curl -X POST 'http://localhost:8069/api/hr.employee/' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","method":"call","id":1,"params":{"data":{"name":"John Doe","work_email":"john@example.com"}}}'
Nested relational field syntax:
fields=["id", "name", ("country_id", ["id", "name"]), ["child_ids", ["id", "name"]]]
# tuple â Many2one
# list â Many2many / One2many
Configuration
Set these environment variables before starting Odoo:
export SECRET_KEY="your-strong-random-secret" # required in production export EXPIRATION_IN_SECONDS=3600 # optional, default 3600
â A default secret key is used if SECRET_KEY is not set. Always override it in production.
Resources
- OpenAPI spec: SwaggerHub
- Documentation: GitBook
Alejandro Cora González
alek.cora.glez@gmail.com
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module