5

I need to create an API so an external client can perform actions on my custom extensions database table.

What would be the right approach?

  1. Should I use https://api.joomla.org/cms-3/ for this? How?! I did not find any examples.
  2. Put the API in a separate directory (for example /api/) and include the Joomla framework into my php?
  3. Or create a MVC extension, for example com_myapi?
  4. Should I use REST or any other method?
  5. Would com_api be a good start? (https://github.com/techjoomla/com_api) Did not find any documentation however…

The external client should be able to:

PUT - Modify an existing object on the server
POST - Create a new object on the server
DELETE - Remove an object on the server

I should then return a response (ok, or a specific error). JSON?

OR…. Am I overlooking some obvious other great solution?

Any suggestion is welcome!

9

There are a few options, but I use the jBackend extension.

Some positives of jBackend.

  • Nice clean JSON
  • Comes with good boilerplate code to get started
  • Manages API keys API endpoint code transmits and receives data
  • Basically exposes many common CMS functions as API endpoints
  • Has a normal looking Joomla admin UI for managing API keys
  • Documentation is good
  • Code is well structured and easy to read

We've been using it for a while so Joomla can be a Backend for mobile Apps. I did a talk about this at J&Beyond last week, which you can find at http://jandbeyond.org/programme.html?view=session&id=45&return=L3Byb2dyYW1tZS5odG1s

More details about jBackend are at http://www.selfget.com/products/jbackend.html . I think there is also a RedComponent extension that does a similar thing.

Whilst at J&Beyond, I attended Chris Davenport's talk on Joomla 3.6 and Beyond, which had some great details on Joomla's API features that may arrive in 3.6 - http://jandbeyond.org/programme.html?view=session&id=74&return=L3Byb2dyYW1tZS5odG1s

  • I just watched the video of jBackend, and it looks very promising. Thank you! – COBIZ webdevelopment Jun 4 '15 at 19:16
  • 2
    Ok, they/you got me convinced just bought the extension ;-) – COBIZ webdevelopment Jun 4 '15 at 19:30
3

If you need clean REST urls like : [GET] api/articles/1

You can have a look to my project : https://github.com/pvullioud/japi

or if you don't wont to use plugins, you have a more simple exemple here https://github.com/pvullioud/joomla-slimframework

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.