Get joomla content as JSON using a REST API
All articles requests can be cached locally
Make sure you have composer installed and
cd into the root of the project then Run composer update
Copy the 'env.example' file to '.env' in the root directory and modify the values to match your joomla details
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=myjoomlasite
DB_TABLE_PREFIX=Fo00_
DB_USERNAME=root
DB_PASSWORD=
APP_VERSION=1.0.0
APP_NAME=JoomJSON
APP_AUTHOR=@morrismukiri
To retrieve joomla content, call the api using following url format
-
GET /articles
Returns
JSON Array of articles in the format
[ { "id": 52, "title": "Article title", "images": "{\"image_intro\":\"\",\"float_intro\":\"\",\"image_intro_alt\":\"\",\"image_intro_caption\":\"\",\"image_fulltext\":\"\",\"float_fulltext\":\"\",\"image_fulltext_alt\":\"\",\"image_fulltext_caption\":\"\"}", "introtext": "html text", "publish_up": "2015-09-02 08:07:33", "created": "2015-09-02 08:07:33", "fulltext": "", "intro_image": "images/scope4.jpg" }, { "id": 54, "title": "Second Article title", "images": "{\"image_intro\":\"\",\"float_intro\":\"\",\"image_intro_alt\":\"\",\"image_intro_caption\":\"\",\"image_fulltext\":\"\",\"float_fulltext\":\"\",\"image_fulltext_alt\":\"\",\"image_fulltext_caption\":\"\"}", "introtext": "html text", "publish_up": "2016-05-03 10:37:13", "created": "2016-05-03 10:37:13", "fulltext": "", "intro_image": "images/cool_pic1.jpg" } ]
You can limit the number of articles by appending the maximum number of articles to the url i.e
GET articles/100
to limit top 100 -
GET /articles/x
where x is the number of articles to get, ordered by date publishedReturns an array of JSON objects as above
-
GET /article/x
where x is the id of the article to get eg 52Returns
Article found
{ "id": 52, "title": "Article title", "images": "{\"image_intro\":\"\",\"float_intro\":\"\",\"image_intro_alt\":\"\",\"image_intro_caption\":\"\",\"image_fulltext\":\"\",\"float_fulltext\":\"\",\"image_fulltext_alt\":\"\",\"image_fulltext_caption\":\"\"}", "introtext": "html text", "publish_up": "2015-09-02 08:07:33", "created": "2015-09-02 08:07:33", "fulltext": "", "intro_image": "images/scope4.jpg" }
Article not found
{ "error": "Article can not be found" }
-
GET /categories
Returns an array of JSON Objects( structure below) of all categories
-
GET /category/x
where x is the category id eg 2Returns
Success
{ "id": 2, "asset_id": 27, "parent_id": 1, "lft": 1, "rgt": 2, "level": 1, "path": "uncategorised", "extension": "com_content", "title": "Uncategorised", "alias": "uncategorised", "note": "", "description": "", "published": 1, "checked_out": 0, "checked_out_time": "0000-00-00 00:00:00", "access": 1, "params": "{\"category_layout\":\"\",\"image\":\"\"}", "metadesc": "", "metakey": "", "metadata": "{\"author\":\"\",\"robots\":\"\"}", "created_user_id": 42, "created_time": "2011-01-01 00:00:01", "modified_user_id": 0, "modified_time": "0000-00-00 00:00:00", "hits": 0, "language": "*", "version": 1 }
not found
{ "error": "Category not found" }
-
GET category/x/article
Where x is the category idReturns JSON object array of articles in the category
-
GET articles/featured/x
Where x is the maximum number of articles to return. it is optional and defaults to 10 Returns JSON object array of articles marked as featured. -
GET articles/latest/x
Where x is the maximum number of articles to return. it is optional and defaults to 10 Returns JSON object array of recently published articles. -
GET articles/latest/tag/name/x
where name is the tag name and x is the maximum count of articles to return