Availability |
Odoo Online
Odoo.sh
On Premise
|
Community Apps Dependencies | Show |
Lines of code | 2806 |
Technical Name |
kw_api_connector |
License | LGPL-3 |
Website | https://kitworks.systems/ |
Versions | 16.0 |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Community Apps Dependencies | Show |
Lines of code | 2806 |
Technical Name |
kw_api_connector |
License | LGPL-3 |
Website | https://kitworks.systems/ |
Versions | 16.0 |
API Connector
Technical module that provides functionality to create API connectors in Odoo. This module helps to establish and manage connections with external APIs, handle requests and responses, and maintain logs of API interactions.
Key features include:
- API Connection Management: Create and manage multiple API connections
- Request Handling: Handle API requests with proper error handling and logging
- Response Processing: Process API responses with data validation
- Integration with HTTP Request Log: Automatic logging of all API interactions
Developer Guide
Configuration
1. Create Your API Connector Model:
from odoo import models, fields class MyAPIConnector(models.Model): _name = 'my.api.connector' _inherit = 'kw.api.connector' _description = 'My API Connector'
2. Create Your API Credentials Model:
class MyAPICredential(models.Model): _name = 'my.api.credential' _inherit = ['kw.api.credential', 'generic.mixin.transaction.utils', 'kw.http.request.log.source.mixin'] _description = 'My API Credentials' api_connector_id = fields.Many2one( 'my.api.connector', # Reference to your connector model )
3. Create API Connector Record:
# First, create the connector connector = env['my.api.connector'].create({ 'name': 'My API Service', 'api_url': 'https://api.example.com', 'is_api_token_used': True, 'is_api_token_static': False })
4. Create API Credentials:
# Then create credentials linked to the connector credentials = env['my.api.credential'].create({ 'name': 'My API Connection', 'api_connector_id': connector.id, 'active': True, 'company_id': env.company.id })
Making API Requests
Basic API Request:
# Use the api_request method from credentials response = credentials.api_request( method='GET', url='/users', headers={'Content-Type': 'application/json'} ) # Check if request was successful if credentials.is_api_success(response): data = response.json()
Request with Parameters:
# Request with data and parameters response = credentials.api_request( method='POST', url='/search', data={ 'query': 'search_term', 'limit': 10 }, headers={'Content-Type': 'application/json'} ) if credentials.is_api_success(response): results = response.json()
Features Details
- Authentication Support:
- Basic Authentication
- API Key Authentication
- OAuth Support
- Request Management:
- Automatic retry on failure
- Timeout handling
- Rate limiting support
- Response Handling:
- JSON response parsing
- Error handling and logging
- Response data validation
Bug Tracker
Bugs are tracked on https://kitworks.systems/requests. In case of trouble, please check there if your issue has already been reported.
Maintainer
KitWorks Systems. Our web site: https://kitworks.systems
We can provide you further Odoo Support, Odoo implementation, Odoo customization, Odoo 3rd Party development and integration software, consulting services. Our main goal is to provide the best quality product for you.
For any questions contact us.
Please log in to comment on this module