View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
13196Feature requestsPluginspublic2022-09-28 13:37
ReporterIvanSteenstra Assigned To 
PrioritynoneSeverityfeature 
Status newResolutionopen 
Summary13196: web HTTP-based RESTful API
Description

Hi,
We would like to have this feature for our purposes. I did find Lime has SOAP, but that has been a deal breaker for another product.

Thanks,
Ivan

TagsNo tags attached.
Bug heat10
Story point estimate
Users affected %

Users monitoring this issue

chimp358, machitgarha

Activities

DenisChenu

DenisChenu

2018-01-18 09:45

developer   ~45889

LimeSurvey have SOAP before, not in last release
Current it's XML-RPC/JSON-RPC

You can make a new API via plugin if needed , see example here : https://gitlab.com/SondagesPro/redoSoapServer

Think we must close this feature request (or create a new "Plugin creation request").

machitgarha

machitgarha

2022-07-07 13:42

reporter   ~70785

Will this feature get merged if I start working on it?

DenisChenu

DenisChenu

2022-07-10 17:12

developer   ~70816

Why ?
Create a plugin : no need to be merged.

machitgarha

machitgarha

2022-07-11 08:10

reporter   ~70818

Because we are going to make an Android application, and REST API is needed. You know how widely REST API is used, to the point LimeStore has one. Could you please tell me why you are against having a REST API? Maybe because LimeSurvey already has an RPC API, or it would have maintenance cost?

In the case of the transition, we can simply call the REST API internally from the RPC procedures, so adding a new RPC procedure would have little cost.

Also, in https://manual.limesurvey.org/Plugins_-_advanced , it is recommended that we should not use internal classes in our plugins.

DenisChenu

DenisChenu

2022-07-11 10:12

developer   ~70819

Could you please tell me why you are against having a REST API?

I'm not against a REST API (i don't really care).
I'm against adding new feature to maintain by core developer when we already have a lot of issue not fixed.

the point LimeStore has one.

Currently yes, but it must come back. And if you want : you can improve it to allow more plugin update system … for example : allow to have different URL for limestore.

machitgarha

machitgarha

2022-07-11 10:23

reporter   ~70820

Alright. So I'm going to create a plugin for that. Should I create a Plugin-category issue, or that relates to core plugins?

DenisChenu

DenisChenu

2022-07-11 10:26

developer   ~70821

Remind : i'm an external dev … i give my opinion. Not LimeSurvey all dev decision here …

machitgarha

machitgarha

2022-07-11 10:29

reporter   ~70822

It seems this issue doesn't get attention from the internals, so that's completely OK. :)

So you have experience with plugin development... What do you think about my last question?

DenisChenu

DenisChenu

2022-07-11 10:32

developer   ~70823

I don't have answers :)

Can try : https://forums.limesurvey.org/forum/news/122416-discord-channel-for-limesurvey-community
But remind : it's holiday time.

machitgarha

machitgarha

2022-07-11 10:37

reporter   ~70824

OK. Thanks for you help!

ollehar

ollehar

2022-07-11 12:05

administrator   ~70829

We want to develop a REST API ourselves. It's in our pipeline. Nothing stops you from making your own plugin API, of course.

DenisChenu

DenisChenu

2022-07-11 12:06

developer   ~70830

Then can be included in core plugins after @ollehar ?

ollehar

ollehar

2022-07-11 12:07

administrator   ~70831

Probably not, since we will be using Yii 3 for our approach.

DenisChenu

DenisChenu

2022-07-11 12:07

developer   ~70832

? Using Yii 3 disable plugins system ?

machitgarha

machitgarha

2022-07-11 12:13

reporter   ~70833

@ollehar , so may I contribute to the progress you're making, instead of working on a separate plugin, if it's going to be made in the open, to prevent duplicating the effort?

ollehar

ollehar

2022-07-11 12:14

administrator   ~70834

@machitgarha, maybe, when we have the basic architecture up and running. Do you know Yii 3 anything?

machitgarha

machitgarha

2022-07-11 12:20

reporter   ~70835

No. But that should not matter, as having a REST API is a must in our side, I would have to start learning it.

How much would it take to reach the basic architecture? Asking because we have a deadline for our development, and I want to have the REST API as soon as possible.

machitgarha

machitgarha

2022-07-11 12:21

reporter   ~70836

Can't I participate in the warming-up process itself? I mean, is it an internal or restricted process?

DenisChenu

DenisChenu

2022-07-11 12:21

developer   ~70837

ASAP : the only way is plugin …

machitgarha

machitgarha

2022-07-11 12:33

reporter   ~70838

In the case of a plugin, if I start developing it using Yii 2 (maybe using some of Yii 3 patterns for easier transition), would it be a chance for my plugin to be moved into the core (maybe using yii2-openapi package)?

Yii 3 is not released yet, and maybe not anytime soon, so basing my plugin on it is not a good idea.

ollehar

ollehar

2022-07-15 12:32

administrator   ~70957

The design of the API base is internal for now, but maybe we could open it up. But it's based on Yii 3 inside Yii 1.

You'd have to use Yii 1 for your plugin, since that's what LS is using right now.

ollehar

ollehar

2022-07-15 12:33

administrator   ~70958

@machitgarha What's your use-case for the Android app? What API calls would it need?

machitgarha

machitgarha

2022-07-15 20:14

reporter   ~70972

@ollehar, the app's going to be an LS client, providing most of the LS's main functionality. So, we basically want a feature-full API.

BTW, I would use Yii 2 for my plugin, although I know LS is written in Yii 1. The reasons are, the tools available, maybe increasing the chance of forward-compatibility of my API in the case of LS transition, and the chance of inclusion in the LS core. By the latter case, I mean if you publish the Yii3-based API, there might be some missing features that I've implemented.

ollehar

ollehar

2022-07-15 20:20

administrator   ~70973

You're talking about the admin interface? Creating surveys etc?

The most simple API imaginable is to have a POST, GET, PATCH etc for each active record model in the application/models/ folder, but then you need more logic in your app to make sure the data stored is consistent/not broken. The validation inside the active record class will help you some, but not all the way. Such an API can probably be implemented in a couple of hours.

LS might never get ported to Yii 2, but rather from Yii 1 to Yii 3 instead.

machitgarha

machitgarha

2022-07-15 20:36

reporter   ~70974

@ollehar, yes

I would still use Yii 2 for the plugin, as I don't have hope for Yii 3 to be released anytime soon.

BTW, thanks for your help.

ollehar

ollehar

2022-07-15 20:52

administrator   ~70975

I don't think anyone ever made an LS plugin in Yii 2... You'd have to bootstrap Yii 2 inside your plugin, after Yii 1 is already started. It's not impossible, but I don't know if it's easy. I'd recommend Yii 1, for less headache.

machitgarha

machitgarha

2022-07-15 20:55

reporter   ~70976

@ollehar, thanks for your recommendation. I'll look into it.

ollehar

ollehar

2022-07-25 23:31

administrator   ~71134

Quick and dirty-ish example here: https://github.com/olleharstedt/LimeSurveyRestAPIPlugin

License is GPL2.

DenisChenu

DenisChenu

2022-07-26 10:10

developer   ~71136

Quick and dirty-ish example here: https://github.com/olleharstedt/LimeSurveyRestAPIPlugin

?
$this->subscribe('newDirectRequest');
You need to subscribe to https://manual.limesurvey.org/NewUnsecureRequest for $_POST (and maybe other) , no ?

ollehar

ollehar

2022-07-26 10:29

administrator   ~71137

Last edited: 2022-07-26 10:30

You need to subscribe to https://manual.limesurvey.org/NewUnsecureRequest for $_POST (and maybe other) , no ?

Yes, maybe. :)

But actually, I'm not sure if this is a good approach... Perhaps it exposes too much of the internal database structure by mapping to active record classes directly instead of to "domain elements". Maybe it would be better to REST-ify the older remote api instead. :d

Also, it's not really REST if you can't authenticate using the API. Permission checks assume a PHP session is established using admin login or such. Maybe that can be fixed.

DenisChenu

DenisChenu

2022-07-26 10:49

developer   ~71138

I mean for evolution :)

Currently not needed …

machitgarha

machitgarha

2022-07-26 20:34

reporter   ~71162

@ollehar, thanks for the prototype. Currently, I subscribed to beforeControllerAction event. Not sure which one is actually better.

ollehar

ollehar

2022-07-26 21:26

administrator   ~71163

Yeah, that'd work too. You can do it without event if you use plugin/ajax controller action, but then it assumes a login session, and will redirect if you're not logged in. Which is probably not what you want for an API.

DenisChenu

DenisChenu

2022-07-27 10:16

developer   ~71165

With beforeControllerAction : i replace default remotecontrol for specific function (when user can not update the link, use different link for each call) https://gitlab.com/SondagesPro/Authentification/AuthRemoteToken/-/blob/main/AuthRemoteToken.php#L559

But here : i think https://manual.limesurvey.org/NewUnsecureRequest can do the job. Just a different link :)

machitgarha

machitgarha

2022-07-27 22:36

reporter   ~71205

@DenisChenu, really thanks for the help. It seems beforeControllerAction only listens for GET requests, which isn't suitable for a REST API. Going to subscribe to newUnsecureRequest. :)

machitgarha

machitgarha

2022-07-27 23:51

reporter   ~71208

Oops, hell no. beforeControllerAction works great, my bad. Didn't know calling App()->end() is necessary for the PluginBase::log() to work, specially when the request is non-GET. :)

DenisChenu

DenisChenu

2022-07-28 08:09

developer   ~71210

beforeControllerAction only listens for GET requests

No : beforeControllerAction happen for ALL LimeSurvey (code) request :)
(no css/js/png or direct PHP link)

You find yourself.

Didn't know calling App()->end()

$event->set('run', false); must work too .

Possible output
run as boolean, if false : the controller/action are not called. LimeSUrvey do nothing. Then you can do your own page/system to replace any action.

machitgarha

machitgarha

2022-07-28 08:54

reporter   ~71215

$event->set('run', false); must work too.

I did that. The problem was something else. Thanks for the help!

ollehar

ollehar

2022-07-28 10:58

administrator   ~71219

You need to consider how to do authentication too. That's supported in the old RPC, but not in my trashy prototype. That's why I started refactor the old RPC a little, to see if it's possible to put a RESTy facade in front of it.

machitgarha

machitgarha

2022-09-28 13:29

reporter   ~71996

Hello. I've built a LimeSurvey plugin providing a RESTful API. It's not complete yet, but provide the main functionality for sending responses. Here it is: https://github.com/machitgarha/limesurvey-rest-api/

I'll be happy if you - anyone who is reading - send feedback like opening issues, or contribute in the project.

Thanks to Mr. Denis Chenu and Mr. Ollehar for their helpful comments and code.

P.S: Sorry for saying we want a feature-full API. I was wrong; it was not the case. :)

ollehar

ollehar

2022-09-28 13:30

administrator   ~71997

Nice. We've been working on a core REST API too, last weeks. It will be in dev branch, soon-ish.

machitgarha

machitgarha

2022-09-28 13:37

reporter   ~71998

Great! I hope my plugin to be helpful for some, at least until the core REST API arrives... Keep up the good work. :)

And thanks for giving a star. :)

Issue History

Date Modified Username Field Change
2018-01-17 16:17 IvanSteenstra New Issue
2018-01-18 09:45 DenisChenu Note Added: 45889
2022-07-07 13:42 machitgarha Note Added: 70785
2022-07-07 13:42 machitgarha Bug heat 2 => 4
2022-07-10 10:25 machitgarha Issue Monitored: machitgarha
2022-07-10 10:25 machitgarha Bug heat 4 => 6
2022-07-10 17:12 DenisChenu Note Added: 70816
2022-07-11 08:10 machitgarha Note Added: 70818
2022-07-11 10:12 DenisChenu Note Added: 70819
2022-07-11 10:23 machitgarha Note Added: 70820
2022-07-11 10:26 DenisChenu Note Added: 70821
2022-07-11 10:29 machitgarha Note Added: 70822
2022-07-11 10:32 DenisChenu Note Added: 70823
2022-07-11 10:37 machitgarha Note Added: 70824
2022-07-11 12:05 ollehar Note Added: 70829
2022-07-11 12:05 ollehar Bug heat 6 => 8
2022-07-11 12:06 DenisChenu Note Added: 70830
2022-07-11 12:07 ollehar Note Added: 70831
2022-07-11 12:07 DenisChenu Note Added: 70832
2022-07-11 12:13 machitgarha Note Added: 70833
2022-07-11 12:14 ollehar Note Added: 70834
2022-07-11 12:20 machitgarha Note Added: 70835
2022-07-11 12:21 machitgarha Note Added: 70836
2022-07-11 12:21 DenisChenu Note Added: 70837
2022-07-11 12:33 machitgarha Note Added: 70838
2022-07-15 12:32 ollehar Note Added: 70957
2022-07-15 12:32 ollehar Category Central participant database => Plugins
2022-07-15 12:33 ollehar Note Added: 70958
2022-07-15 20:14 machitgarha Note Added: 70972
2022-07-15 20:20 ollehar Note Added: 70973
2022-07-15 20:36 machitgarha Note Added: 70974
2022-07-15 20:50 machitgarha Issue End Monitor: machitgarha
2022-07-15 20:50 machitgarha Bug heat 8 => 6
2022-07-15 20:50 machitgarha Issue Monitored: machitgarha
2022-07-15 20:50 machitgarha Bug heat 6 => 8
2022-07-15 20:52 ollehar Note Added: 70975
2022-07-15 20:55 machitgarha Note Added: 70976
2022-07-25 23:31 ollehar Note Added: 71134
2022-07-26 01:26 chimp358 Issue Monitored: chimp358
2022-07-26 01:26 chimp358 Bug heat 8 => 10
2022-07-26 10:10 DenisChenu Note Added: 71136
2022-07-26 10:29 ollehar Note Added: 71137
2022-07-26 10:30 ollehar Note Edited: 71137
2022-07-26 10:49 DenisChenu Note Added: 71138
2022-07-26 20:34 machitgarha Note Added: 71162
2022-07-26 21:26 ollehar Note Added: 71163
2022-07-27 10:16 DenisChenu Note Added: 71165
2022-07-27 22:36 machitgarha Note Added: 71205
2022-07-27 23:51 machitgarha Note Added: 71208
2022-07-28 08:09 DenisChenu Note Added: 71210
2022-07-28 08:54 machitgarha Note Added: 71215
2022-07-28 10:58 ollehar Note Added: 71219
2022-09-28 13:29 machitgarha Note Added: 71996
2022-09-28 13:30 ollehar Note Added: 71997
2022-09-28 13:37 machitgarha Note Added: 71998