ElkArte Community

Elk Development => Feature Discussion => Topic started by: Ant59 on September 09, 2015, 10:27:19 am

Title: JSON API
Post by: Ant59 on September 09, 2015, 10:27:19 am
Looking through Elk's source, it seems we have quite a mess of different ways to interact with the backend, including the xmlhttp action, which calls Xml.controller.php along with a handful of JSON sub-actions scattered around the place.

Can we make a 1.1/2.0 goal to have a standardised JSON API? Such that if we implement a proper router, calls specifying JSON, will have JSON values returned and those not specifying will be returned through the templates as usual.

Then we can use JSON as a means of both AJAX calls on templates and also stuff like native mobile apps.
Title: Re: JSON API
Post by: Spuds on September 09, 2015, 01:06:41 pm
I'd love to see this as well!

At one point all ajax was done through that xmlhttp request, including the callbacks.  As more jquery found its way in, and we did not have json limitations of older php versions, newer calls went the $.ajax route with a mixture of json or xml

Anyway all of that really needs to be standardized and rationalized a bit, I don't see why it can't be started (or even completed) on 1.1, just needs someone to come up with some implementation ideas.
Title: Re: JSON API
Post by: emanuele on September 09, 2015, 02:33:26 pm
Yup!
That would be really awesome!

There is already a kind of start on the standardization: in theory, all the calls with an "api" parameter in the url should return either an xml or a json request (the api parameter can accept also a "json" or "xml" value (api=json or api=xml) to define what to return).
So, if the controller knows how to deal with this "api" parameter it can return the proper data.

That said, even that is not really very well standardized. LOL

Feel free to play with any solution you think it's best!