Looking for more information on API module
Hi UNA,
We need information on API module provided by una in app market.
As per my understanding API module will have the endpoints of una module/features.
this is my understanding of flow: mobile app > api endpoints > service calls > php script > database (please correct me here)
As of now API module is showing blank. we need one example on how to add endpoints into the API module.
Also, regarding custom endpoints should we create new API module and add custom endpoints there ..or should we use API module provided by una.
thanks.
-
-
·
LeonidS
- ·
Hello travis k !
Did you review this manual https://github.com/unaio/una/wiki/Dev-API ?
-
·
LeonidS
-
- · travis k
-
·
In reply to LeonidS
- ·
I want to know more on new custom api endpoints. what will be the right way to create it ..
and how will the flow. from end user to una database .. will api endpoints will be using service calls the way website front end are using..
-
- · travis k
-
·
In reply to LeonidS
- ·
-
-
·
Alex T⚜️
- ·
To add custom API endpoint to UNA, please create an empty module first, I think it's better to rename modules/boonex/api module to your own and delete or replace existing endpoints with yours.
To add custom endpoint - add service function, for example to add endpoint which get time you can add something like this:
public function serviceClock() { return ['time' => date('H:i:s')]; }
Then declare if you want to use this endpoint with authentication or not, for public endpoint add name of the endpoint to serviceGetPublicServices method:
public function serviceGetPublicServices() { $a = parent::serviceGetPublicServices(); return array_merge($a, array ('Clock' => '')); }
for protected endpoint add it the same way but to serviceGetSafeServices method.
After above you will be able to call your custom endpoint with the following URL:
http://example.com/m/oauth2/com/clock?client_id=1234abcd&module=your_modulename
You will get response in JSON format
-
·
Alex T⚜️