News:

Support the VirtueMart project and become a member

Main Menu

REST Api

Started by sprachrohr, September 02, 2016, 16:22:51 PM

Previous topic - Next topic

sprachrohr

Hallo,

is there a REST Api (JSON-format) for Virtuemart to connect with other systems? Or are there any plans to develop such an api?

Thanks for your answer!

Best regards
Dirk

balai

No there is no such an api incorporated into VM.
Hence i think something like an API can be developed as a 3rd party plugin using the ajax component of joomla

sprachrohr

ok, thanks for your answer! so i think i have to code it by myselfe.

balai

#3
I developed such a plugin which at the moment can be used to return/expose products and is based on the ajax component of system.
If you like i can upload it to github and you can contribute to extend it even more

sprachrohr

thank you very much for your support. but i am not sure, if i have the time to contribute to extend your product.

i think i have to talk with my customers first. maybe we talk later again?

best regards!

Milbo

You can extend vm by a plugin and use joomla views and return them as json. There are a lot possibilities.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

So just checking that I am not saying nonsense here.

a html webserver is always a REST API, already. REST is for me some of these triggerwords, which imply some structure, but actually it says almost nothing. https://en.wikipedia.org/wiki/Representational_state_transfer

REST API just means that you get the same result, when you use the a link. We could also say that as long we cannot add logindata to the URL, joomla is not RESTful.

So, to say VM has a REST API or not, does not give you any information to finish your job. At the end you want to know, if your job/problem is already implented restful. For example
"give me all orders, filtered by". This works already, else you could not check the orders in BE. The only missing thing is the login. You would have to send a login first and then you can do this request. At the moment the representation is html, there is no problem to add a json output. That is imho the real point. People asking for REST often mean, if they can download orders, products, users list by a simple URL call and that the representation is in json. But that is actually not defined by REST.

For example CRUD https://en.wikipedia.org/wiki/Create,_read,_update_and_delete is a real developer paradigma, which is implemented as BREAD in VM.

and to clear the question.
At the moment there is no possibility to access data as json by URLs, which could be useful for ERPs, CRMs and so on. We just use the json for ajax.

We use most time a "simple" ajax, which returns html, which we just use to replace the old html and thats it. So when we extend this system to the BE (or FE as manager), then we would get the whole list, with all the html. Nasty to use it for other applications.

The other way is to return just a json list with the abstract data and to replace the data in any field (visible on the page) by the json data. It sounds more modern, but actually it is just fast on a big computer, when you check such a page on smartphone you can see first the list, which then gets filled with data. Because the replace actions are expensive.

For example a list with 50 Orders, each with more than 10 informations fields, you would have more than 500 replace actions, compared to one by our "simple" solution. The work is then done mainly on the server, writing the normal html. Of course, when I would write it that way, I would write html by js and replace line by line (50 replacements).

It is planned to unify the ajax system, so that it returns always json, which keeps the html. You can see this technic in the Amazon plugin (vm3.0.18)
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/