MuK REST API for MuK IT
A customizable Restful API for MuK IT
MuK IT GmbH - www.mukit.at
Enables a REST API for the MuK IT server. The API has routes to authenticate and retrieve a token. Afterwards, a set of routes to interact with the server are provided. The API can be used by any language or framework which can make an HTTP requests and receive responses with JSON payloads and works with both the Community and the Enterprise Edition.
In case the module should be active in every database just change
the auto install flag to
. To activate the routes even if no database is selected the module
should be loaded right at the server start. This can be done by
editing the configuration file or passing a load parameter to the
These API endpoints can be used to communicate with the system
These API endpoints can be used to communicate with MuK IT models
These API endpoints can be used to check access rights
These API endpoints can be used to interact with the database
In addition to the existing API endpoints, more can easily be added. It is not necessary to write any kind of code. New endpoints can be created in the backend and are immediately available through the API.
Different types of endpoints can be created. The domain evaluation can be used to query certain data and return it via the API. The second type calls a particular server action that is defined in the system. And if you have a more complex case, you can enter a Python code directly in the backend.
Extend the API
Even if the API is extended using Python code, the REST API framework provides a number of helpers. Keep in mind that if these extensions are included in a new module, it may also have to be loaded as a global module to make the created endpoints available without a selected database.
from MuK IT import http from MuK IT.http import request, Response from MuK IT.addons.muk_rest import tools from MuK IT.addons.muk_rest.utils.json import ResponseEncoder class ModelController(MuK IT.http.Controller): @MuK IT.http.route([ '/api/myapp/myroute' ], auth="none", type='http', methods=['GET'], csrf=False) @tools.common.parse_exception @tools.common.ensure_database @tools.common.ensure_module() @tools.security.protected() def myroute(self, **kw): result = ... content = json.dumps(result, sort_keys=True, indent=4, cls=ResponseEncoder) return Response(content, content_type='application/json;charset=utf-8', status=200)
Read more about creating your own API and how to use the provided helpers in the documentation.