Please help, I Want to use REST api in joomla 2.5 !! I searched a lot and spend many days in Github and techjoomla. I didn\'t get it how to install API extension or Plugin and u
You mentioned that you are using Joomla 2.5 (which is no longer actively developed or supported). If it is possible for you to upgrade / migrate to Joomla 3.4.x, your options open up.
I ended up developing a RESTful API for Joomla 3.4.x, powered by the Slim PHP micro-framework. Please note that this is a commercial Joomla package, so if you were interested in "free", this isn't it.
The package includes the following:
Services Control Panel component Joomla "services" add-on library which includes a version of Slim v2.6.2 (along with several other libraries) obtain via composer and normally found in the vendor folder. More on this later... Services Joomla Plugin Services REST Plugin Services Slim Configuration Plugin Slim JSON API View plugin Slim JSON API Middleware plugin You might ask, "What is the point of all these plugins?"
The answer is that it allows for compartmentalization of functionality of the core components and opens the door for an easily extensible services routes architecture. Note that new plugins could easily be added with Joomla ACL restricting access to those new routes, for example.
The Services Control Panel allows for creation of tokens on a per-user basis (or even multiple tokens per Joomla user). It also allows the end user to configure the Slim micro-framework parameters and even include a threshold for the API rate-limiting functionality (currently based on requests-per-minute). Actually, that part is totally awesome as it provides live feedback on the state of the API rate threshold within the response header.
The cAPI Core package ("cAPI", short for "Constant API" because everything needs a product name...) is just that - a core package. There is a host of add-ons currently in development, the first one being a secure LDAP JSON API (which connects to Microsoft Active Directory), with lots more cool add-ons to come.
The whole point of all this is to say that, basically, your request has been answered and now a commercially supported solution has finally arrived. Plus, instead of reinventing the wheel, I based the extension on a popular, existing micro-framework (Slim), making it easier for developers to work with or develop on the core, pluggable, framework.
So, you get the best of Joomla (robust ACL, advanced plugin architecture, wealth of extensions) and Sim (proven, standards-compliant, mature RESTful PHP micro-framework), all in one easy to install package.
Exposing a website via an easily queryable API should not be taken lightly. I would hope anyone choosing to do this would implement 100% HTTPS access and security-harden their server(s).
You can find more information here: http://getcapi.org
Hope this gets you going in the right direction.
Service Endpoints and CORS Ajax calls
/api/v1/user/ - Can be used to log a user in and out and returns the activated Joomla session in the response - This also provides for multimodal authentication (both via token in header or username & password in URL string). Basically, it works with your needs. - You force a user logout like this: /api/v1/user/logout/username/joomlasessionid
Basically, this is tailor-made for driving remote services or, say iOS or Android apps.
/api/v1/content/ - Provides basic ability to create, retrieve and update content - This functionality, while it exists, I would consider it under active development and will become MUCH more robust over time.
I have embedded a sample jQuery Ajax syntax followed by the html for the div container that can display the output. Note that the headers line is optional (depends on the requirements of the API).
jQuery('button').on('click', function() {
var requestUrl= "https://www.annatech.com/api/v1/slim/swagger";
var start = new Date().getTime();
jQuery.ajax({
url: requestUrl,
type: "GET",
success: function (resultData) {
totalTime = new Date().getTime() - start;
jQuery( "#title" ).empty();
jQuery( "#requestUrl" ).empty();
jQuery( "#totalTime" ).empty();
jQuery( "#output" ).empty();
jQuery( "#version" ).empty();
jQuery( "#output" ).append(resultData.info.description).html;
jQuery( "#version" ).append('Version '+resultData.info.version).html;
jQuery( "#title" ).append(resultData.info.title).html;
jQuery( "#requestUrl" ).append(requestUrl).html;
jQuery( "#totalTime" ).append(totalTime+ 'ms').html;
},
error: function (jqXHR, textStatus, errorThrown) {
alert('error');
},
timeout: 120000
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button>Send CORS</button>
<p>Request URL: <span id="requestUrl"></span></p>
<p>Response Time: <span id="totalTime"></span></p>
<h2><span id="title"></span></h2>
<h3><span id="version"></span></h3>
<div id="output"></div>
It should go without saying that all cAPI Core package improvements are included in the annual subscription fee. Add-ons are (will be) billed and supported separately.
About Documentation
Please note that the documentation is still under development, but if you would like to contact me directly (or through https://www.annatech.com/annatech-llc.html), I can go over the details with you. Also, I would recommend that you look over the Slim micro-framework so you can understand the basic route design http://docs.slimframework.com.
Let me know if you have any other questions.