Is it possible to call a function or a script with a REST API

apiapi-designbackendmobilemulti-platform

Let us say that I want to create a workout app and a website, the user enters his workout stats and the app display his stats with graphs percentage and such.

This is an example I don't want to create a workout app, just to understand how platforms work.

Assuming that I want to have an Android, iOS app and a website. All with the same functionalities.

From what I read, REST APIs are used for back end.
This is an easy way of exchanging data between an app and the database.
But what about operations on the data ?

Let us say I want to compute the average workout time (or something much more complex). Do I have to compute it on the device so create the algorithm 3 times (Android, iOS and web) or run all computations on the server ?

I tried to read the documentation of a REST api (Eve for Python) but I only found data operations like get update and delete.

Does REST APIs provides only data operation, is it possible to call a function or a script with a REST API ?

Maybe I misunderstood everything so could someone explain me how back ends works for a multi device platform ?

Best Answer

You forgot about POST.

You need to learn a bit more about REST (you actually need to learn a whole bunch of other stuff as well), but suffice it to say that if you want to do any other operation besides a GET, PUT, PATCH or DELETE, it's probably going to be a POST.

Also, note that there are other ways to communicate with a server besides REST. Stand up a WebSocket, and you can pretty much do whatever you want.

In any case, a GET suffices for what you want to do, if you want to stay with REST.

Related Topic