Rest API for allowing configuration changes from remote system

Hello,

Does anyone know of an existing Rest API that allows remote configuration of a FreePBX deployment. in particular, CRUD against extensions.

If nothing exists, I might look into creating something. That said I have very little experience with PHP and would prefer to write the Rest API in something like node or .net core.

Looking through the docs it appears Bootstrap (https://wiki.freepbx.org/display/FOP/Bootstrap) would be the best place to hook into FreePBX and using something like Dnode (https://github.com/bergie/dnode-php) to allow piping the commands across to Node.

Thoughts / feedback would be greatly appreciated.

dnode-php seems like overkill because the library is written around bi-directional communication with PHP scripts. There’s no point in doing that with FreePBX and that’s not a Rest API at all (are you looking for a Rest API or something else?). Since FreePBX is written around submitting webpages on a browser the need for bi-directional communication is slim. A true RestAPI framework is developed on a call/response type model. You want to PUT something and I return with an HTTP status code. You want to DELETE something and I return with an HTTP status code. Very push type methodology.

We have a Rest API module but it’s not all that great. It’s open source. In 15 we will be working on revamping it. I don’t think I can give a timeline on 15 but I will say “soon”. Externally I can say that 15 will be reworking backup and reworking restapi as you are the 5 or so person to ask for this in the last year.

Writing an API in another language (like Node or .net) for a library written in PHP is really going to hurt you in the long run. You need to be able to call native php functions otherwise you are just doing database and ami manipulations which you will have to port every time FreePBX makes a change to an underlying method. Not very portable at that stage.

There was a similar project out there in the past that did the same manipulation but using bash scripts (eg it modified the database directly). The script was hyped as a way to avoid the GUI over cool API calls, however it crashed and burned, users quickly realized they couldn’t make calls because FreePBX creates an extension not only through the database but also through several php calls which you would also have to call, there is nothing tricky about what we do (nor are we trying to hide things) but it’s definitely not as easy as “insert into database”

Really there is no way around using PHP. You have to use it to create a RestAPI framework, if you want.

Hi Andrew,

Thanks for your response. I was simply looking at Dnode as a way of calling Php functions and getting the returned value (if there is one) pushed back into the node environment. Inside node is where the Rest API would be built around the calls to the relevant PHP functions.

I don’t want to make database calls or use AMI as I ultimately want users to be able to log into the FreePBX GUI and make changes as if they were all created there in the first place.

Will the REST API module allow calls from external sources?

Hy all is there any update as 2020 ?
I’m a php developer I like to integrate some features from our crm
as add or modify extensions.
I was thonking to emulate post with curl or write a new rest api.
Any suggestions will be appreciate

FreePBX 15 has a new API module.
https://wiki.freepbx.org/display/FOP/PBX+API

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.