Host RESTful API using Wappler

Hi, team,
Is there a possibility to build RESTful API using Wappler?
So this API would be consumed by 3rd parties?

For Example this list of API calls:
GET /api/v1/account - returns list of all accounts.
GET /api/v1/account/12504 - returns account details for account_id:12504
POST /api/v1/account - creates account with payload {“name”:“Supercompany”,“url”:“www.org.com”}
PATCH /api/v1/account/12504 - update account with payload {“name”:“Supercompany”,“url”:“www.org.com”}
DELETE /api/v1/account/12504 - deletes account with id:12504

I’m aware of Serverconnect capabilities, and I see that now it’s possible to create routes for them. But they don’t take into account HTTP request type, like PATCH or DELETE.

So, it’s not possible to create for example this 2 methods of the API with same URL but different HTTP request types.
DELETE /api/v1/account/12504
PATCH /api/v1/account/12504
GET /api/v1/account/12504

1 Like

Yes this is fully posisble.

The Server Connect actions that you define in Wappler are actually your REST API Actions.

If you don’t want to call them directly like dmxConnect/api/action.php you can create a routing that rewrites them to the nice urls that you want.

Actually in Routing Manager you can directly pick a Server Connect Action and make a nice route for it.

1 Like

Hey Alex,

To give you a headstart, you can use a condition to evaluate the method and process accordingly.

{{$_SERVER.REQUEST_METHOD == 'PUT'}}
4 Likes

Nice catch, @mebeingken!
This one for sure helps!

1 Like