Displaying items by tag: module

Saturday, 19 April 2014 00:00

Content Module API

The Content Module is implemented with the plg_jbackend_content plugin. It provides functions related to Joomla content (articles and categories). Here is the list of supported methods.

Get the list of categories

Request parameters

action=get
module=content
resource=categories
rootid=<R> (optional)
recursive=<true or 1> (optional)
countitems=<true or 1> (optional)

Example

<end-point>?action=get&module=content&resource=categories&rootid=<R>&recursive=<false>&countitems=<0>

Example (REST format)

<end-point>/get/content/categories?rootid=<R>

Response

{
    "status": "ok",
    "total": <T>,
    "categories": [
        {
            "id": "<category id>",
            "title": "<category title>",
            "description": "<category description>",
            "parent_id": "<parent category id>",
            "numitems": <items count>
        },
        ...
        {
            "id": "<category id>",
            "title": "<category title>",
            "description": "<category description>",
            "parent_id": "<parent category id>",
            "numitems": <items count>
        }
    ]
}

Notes

If rootid is specified, starts to get subcategories from the specified category id instead of the root category. If recursive is true or 1, get categories and all subcategories, otherwise get only one level (default). If countitems is true or 1, return the number of articles of each category, otherwise do not return this information (default). Category id can be "root" for root node.

 

Get a category

Request parameters

action=get
module=content
resource=categories
id=<N>

Example

<end-point>?action=get&module=content&resource=categories&id=<N>

Example (REST format)

<end-point>/get/content/categories/<N>

Response

{
    "status": "ok",
    "id": "<category id>",
    "title": "<category title>",
    "alias": "<category alias>",
    "description": "<category description>",
    "metadesc": "<meta description>",
    "metakey": "<meta keywords>",
    "metadata": {
        "page_title": "<meta title>",
        "author": "<meta author>",
        "robots": "<meta robots>"
    },
    "language": "<language code>",
    "parent_id": "<category id>",
    "level": "<category level>",
    "numitems": "<N>"
}

Notes

Language can be "*" if any. Category id can be "root" for root node.

 

Get the list of articles

Request parameters

action=get
module=content
resource=articles
catid=<C> (optional)
maxsubs=<S> (optional)
featured=<F> (optional)
limit=<L> (optional)
offset=<O> (optional)
orderby=<field> (optional)
orderdir=<dir> (optional)

Example

<end-point>?action=get&module=content&resource=articles&catid=<C>&maxsubs=<S>&featured=<F>&orderby=<id>

Example (REST format)

<end-point>/get/content/articles?catid=<C>&limit=<L>&offset=<O>

Response

{
    "status": "ok",
    "total": <total articles>,
    "limit": <pagination limit>,
    "offset": <pagination offset>,
    "pages_current": <current page>,
    "pages_total": <total pages>,
    "articles": [
        {
            "id": "<article id>",
            "title": "<article title>",
            "alias": "<article alias>",
            "featured": "<featured>",
            "content": "<article content>",
            "catid": "<article category id>",
            "images": {
                "image_intro": "<image_url_for_intro>",
                "float_intro": "<float_side_for_intro>",
                "image_intro_alt": "<alt_text_for_intro>",
                "image_intro_caption": "<caption_for_intro>",
                "image_fulltext": "<image_url_for_fulltext>",
                "float_fulltext": "<float_side_for_fulltext>",
                "image_fulltext_alt": "<alt_text_for_fulltext>",
                "image_fulltext_caption": "<caption_for_fulltext>"
            },
            "tags": [
                {
                    "id": "<tag id>",
                    "title": "<tag title>",
                    "alias": "<tag alias>",
                    "language": "<tag language>"
                },
                ...
            ],
            "fields": [
                {
                    "id": "<field id>",
                    "title": "<field title>",
                    "name": "<field name>",
                    "type": "<field type>",
                    "default_value": "<default value>",
                    "group_id": "<field group id>",
                    "label": "<field label>",
                    "description": "<field description>",
                    "required": "<field required>",
                    "value": "<field value>",
                    "rawvalue": "<field raw value>"
                },
                ...
            ],
            "metakey": "<meta keywords>",
            "metadesc": "<meta description>",
            "metadata": {
                "robots": "<meta robots>",
                "author": "<meta author>",
                "rights": "<meta content rights>",
                "xreference": "<meta external reference>"
            },
            "language": "<language code>",
            "category_title": "<category title>",
            "category_alias": "<category alias>",
            "author": "<article author>",
            "created_date": "<created date>",
            "modified_date": "<modified date>",
            "published_date": "<publish up date>",
            "unpublished_date": "<publish down date>",
            "state": "<article state>"
            },
            ...
            {
                ...
            }
    ]
}

Notes

State:

  • Published = 1,
  • Unpublished = 0,
  • Archived = 2,
  • Trashed = -2

Max subs:
Number of subcategories to include (default 0=none)

Featured:
hide,only,show (default)

Order by:
id, title, alias, catid, state, created, created_by, ordering (default), hits

Order dir:
asc (default), desc

Dates are in ISO 8601 format (e.g 2017-05-11T10:16:32+00:00)

Property content is present only if plugin's option Content in article list is set.

Property tags is present only if plugin's option Add tags in article list is set.

Property fields is present only if plugin's option Prepare content in article list is set.

 

Get an article

Request parameters

action=get
module=content
resource=articles
id=<N>

Example

<end-point>?action=get&module=content&resource=articles&id=<N>

Example (REST format)

<end-point>/get/content/articles/<N>

Response

{
    "status": "ok",
    "id": "<article id>",
    "title": "<article title>",
    "alias": "<article alias>",
    "featured": "<featured>",
    "introtext": "<article intro text>",
    "content": "<article content>",
    "content_raw": "<article content raw>",
    "catid": "<article category id>",
    "images": {
        "image_intro": "<image_url_for_intro>",
        "float_intro": "<float_side_for_intro>",
        "image_intro_alt": "<alt_text_for_intro>",
        "image_intro_caption": "<caption_for_intro>",
        "image_fulltext": "<image_url_for_fulltext>",
        "float_fulltext": "<float_side_for_fulltext>",
        "image_fulltext_alt": "<alt_text_for_fulltext>",
        "image_fulltext_caption": "<caption_for_fulltext>"
    },
    "tags": [
        {
            "id": "<tag id>",
            "title": "<tag title>",
            "alias": "<tag alias>",
            "language": "<tag language>"
        },
        ...
    ],
    "associations": [
    ],
    "event": {
        "afterDisplayTitle": "<after display title>",
        "beforeDisplayContent": "<before display content>",
        "afterDisplayContent": "<after display content>"
    },
    "fields": [
        {
            "id": "<field id>",
            "title": "<field title>",
            "name": "<field name>",
            "type": "<field type>",
            "default_value": "<default value>",
            "group_id": "<field group id>",
            "label": "<field label>",
            "description": "<field description>",
            "required": "<field required>",
            "value": "<field value>",
            "rawvalue": "<field raw value>"
        },
        ...
    ],
    "cck_fields": [
    ],
    "metakey": "<meta keywords>",
    "metadesc": "<meta description>",
    "metadata": {
        "robots": "<meta robots>",
        "author": "<meta author>",
        "rights": "<meta content rights>",
        "xreference": "<meta external reference>"
    },
    "language": "<language code>",
    "category_title": "<category title>",
    "category_alias": "<category alias>",
    "author": "<article author>",
    "parent_id": "<parent id>",
    "parent_title": "<parent title>",
    "parent_alias": "<parent alias>",
    "parent_route": "<parent route>",
    "created_date": "<created date>",
    "modified_date": "<modified date>",
    "published_date": "<publish up date>",
    "unpublished_date": "<publish down date>",
    "version": "<article version>",
    "hits": "<article hits>",
    "rating": "<article rating>",
    "rating_count": "<article rating count>",
    "state": "<article state>"
}

Notes

State:

  • Published = 1,
  • Unpublished = 0,
  • Archived = 2,
  • Trashed = -2

Dates are in ISO 8601 format (e.g 2017-05-11T10:16:32+00:00)

Language can be "*" if any.

Property content_raw is present only if plugin's option Include content raw is set.

Property event is present only if plugin's option Show article event is set.

Property cck_fields is present only if plugin's option Include CCK is set.

 

Get the list of articles by tag id

Request parameters

action=get
module=content
resource=tagarticles
tagid=<T1,T2,...,Tn>
limit=<L> (optional)
offset=<O> (optional)

Example

<end-point>?action=get&module=content&resource=tagarticles&tagid=<T>&limit=<L>&offset=<O>

Example (REST format)

<end-point>/get/content/tagarticles?tagid=<T>&limit=<L>&offset=<O>

Response

{
    "status": "ok",
    "total": <total articles>,
    "limit": <pagination limit>,
    "offset": <pagination offset>,
    "pages_current": <current page>,
    "pages_total": <total pages>,
    articles: [
        {
            "id": "<article id>",
            "title": "<article title>",
            "alias": "<article alias>",
            "featured": "<featured>",
            "content": "<article content>",
            "images": {
                "image_intro": "<image_url_for_intro>",
                "float_intro": "<float_side_for_intro>",
                "image_intro_alt": "<alt_text_for_intro>",
                "image_intro_caption": "<caption_for_intro>",
                "image_fulltext": "<image_url_for_fulltext>",
                "float_fulltext": "<float_side_for_fulltext>",
                "image_fulltext_alt": "<alt_text_for_fulltext>",
                "image_fulltext_caption": "<caption_for_fulltext>"
            },
            "tags": [
                {
                    "id": "<tag id>",
                    "title": "<tag title>",
                    "alias": "<tag alias>",
                    "language": "<tag language>"
                },
                ...
            ],
            "metadesc": "<meta description>",
            "metakey": "<meta keywords>",
            "metadata": {
                "robots": "<meta robots>",
                "author": "<meta author>",
                "rights": "<meta content rights>",
                "xreference": "<meta external reference>"
            },
        "category_title": "<category title>",
        "author": "<article author>",
        "published_date": "<article date>"
        },
        ...
        {
            ...
        }
    ]
}

Notes

Dates are in ISO 8601 format (e.g 2017-05-11T10:16:32+00:00)

 

Get an article by alias

Request parameters

action=get
module=content
resource=articlebyalias
id=<alias>

Example

<end-point>?action=get&module=content&resource=articlebyalias&id=<alias>

Example (REST format)

<end-point>/get/content/articlebyalias/<alias>

Response

Same response as "Get an article"

Notes

Same notes as "Get an article".

 

Plugin Settings

jBackend Content Plugin Settings

The following options are available for user plugin:

Option Description
Filter language Filter content by language.
Status Filter content by state.
Access archived articles Allow get article on archived items.
Grant access Skip access permissions check and allow access to articles.
Full image URL Generate absolute URL (i.e. with domain) for images fields.
Force full image URL in content Try to replace relative image URL in content with absolute URL.
Add tags in article list Include article tags in the list of articles.
Prepare content in article list Call onContent events on each article in the list of articles.
Content in article list Include full content in the list of articles.
Show article event Include results of events in the article response.
Include content raw Include raw content (no content plugin) in the article response.
Include CCK Include SEBLOD CCK custom fields in the article response.
Saturday, 19 April 2014 00:00

User Module API

The User Module is implemented with the plg_jbackend_user plugin. It provides functions related to Joomla users and ACL. Here is the list of supported methods.

User login

Request parameters

action=post
module=user
resource=login
username=<username>
password=<password>

Example

<end-point>?action=post&module=user&resource=login&username=<username>&password=<password>

Example (REST format)

<end-point>/post/user/login?username=<username>&password=<password>

Response

{
    "status": "ok",
    "userid": <userid>,
    "username": "<username>",
    "session_id": "<session_id>"
}

 

To avoid to pass credentials in clear it is recommended to expose the endpoint over HTTPS, and to pass username and password as POST variables (it is supported out-of-the-box), or enabling JSON Login option and using a POST method with a JSON payload.

 

User logout

Request parameters

action=get
module=user
resource=logout

Example

<end-point>?action=get&module=user&resource=logout

Example (REST format)

<end-point>/get/user/logout

Response

{
    "status": "ok"
}

 

User registration

Request parameters

action=post
module=user
resource=register
username=<username>
password=<password>
email=<email>
firstname=<firstname>
lastname=<lastname>

Example

<end-point>?action=post&module=user&resource=register&username=<username>&password=<password>&email=<email>&firstname=<firstname>&lastname=<lastname>

Example (REST format)

<end-point>/post/user/register?username=<username>&password=<password>&email=<email>&firstname=<firstname>&lastname=<lastname>

Response

{
    "status": "ok"
}

 

To avoid to pass sensible data in clear it is recommended to expose the endpoint over HTTPS, and to pass variables using POST method (it is supported out-of-the-box), or enabling JSON Register option and using a POST method with a JSON payload.

 

User remind

Sends an email to the user's account with a password remind link.

Request parameters

action=get
module=user
resource=remind
email=<email>

Example

<end-point>?action=get&module=user&resource=remind

Example (REST format)

<end-point>/get/user/remind

Response

{
    "status": "ok"
}

 

User reset

Sends an email to the user's account with a password reset link.

Request parameters

action=get
module=user
resource=reset
email=<email>

Example

<end-point>?action=get&module=user&resource=reset

Example (REST format)

<end-point>/get/user/reset

Response

{
    "status": "ok"
}

 

User profile

Request parameters

action=get
module=user
resource=profile

Example

<end-point>?action=get&module=user&resource=profile

Example (REST format)

<end-point>/get/user/profile

Response

{
    "status": "ok",
    "fields": [
        {
            "id": "<id>",
            "title": "<title>",
            "name": "<name>",
            "language": "<language>",
            "type": "<type>",
            "default_value": "<default value>",
            "context": "<context>",
            "group_id": "<group id>",
            "label": "<label>",
            "description": "<description>",
            "required": "<required>",
            "language_title": "<language title>",
            "language_image": "<language image>",
            "group_title": "<group title>",
            "value": "<value>",
            "rawvalue": "<raw value>"
        },
        ...
    ],
    "_errors": [<_errors>],
    "groups": {
        "<groupid>": "<groupid>"
        ...
    },
    "id": "<id>",
    "name": "<name>",
    "username": "<username>",
    "email": "<email>",
    "block": "<block>",
    "sendEmail": "<sendEmail>",
    "registerDate": "<registerDate>",
    "lastvisitDate": "<lastvisitDate>",
    "activation": "<activation>",
    "params": {
        "admin_style": "<admin_style>",
        "admin_language": "<admin_language>",
        "language": "<language>",
        "editor": "<editor>",
        "helpsite": "<helpsite>",
        "timezone": "<timezone>"
    },
    "lastResetTime": "<lastResetTime>",
    "resetCount": "<resetCount>",
    "otpKey": "<otpKey>",
    "otep": "<otep>",
    "requireReset": "<requireReset>",
    "tags": {
        "typeAlias": <typeAlias>,
        "tags": "<tags>"
    }
}

 

It is possible to filter fields in the response just specifying the field list in the Required fields option.

 

User profile update

Allows to update the user profile (user must be authenticated). The requests must use the POST method with a JSON payload.

Request parameters

action=put
module=user
resource=profile

Example

POST <end-point>?action=put&module=user&resource=profile

Example (REST format)

POST <end-point>/put/user/profile

JSON payload data:

{
    "name": "<name>",
    "username": "<username>",
    "password": "<password>",
    "email": "<email>",
    "profile": {
        "city": "<city>"
        ...
    },
    "com_fields": {
        "field-1": "<value 1>",
        "field-2": "<value 2>"
        ...
    }
}

Response

{
    "status": "ok"
}

 

It is possible to specify any supported field in the payload, but the following fields are mandatory for each request: name, username, password, email

 

User status

Allows to check the current status of the user (guest or logged in), and provides some additional information.

Request parameters

action=get
module=user
resource=status

Example

<end-point>?action=get&module=user&resource=status

Example (REST format)

<end-point>/get/user/status

Response

{
    "status": "ok",
    "is_guest": <0 or 1>,
    "user_id": "<user_id>",
    "session_id": "<session_id>",
    "session_expire": <session_expire>
}

 

Plugin Settings

jBackend User Plugin Settings

The following options are available for user plugin:

Option Description
Auto activate Automatically activate users on registration and skip any notification email.
Extended auth request Process register, remind and reset as an authentication request (i.e. these requests can bypass the access restrictions on the endpoint).
Extended fields Enable support for additional fields in the registration.
External libraries List of paths (relative to JPATH_SITE) of external libraries to load in the registration (one path each row).
Required fields List of fields to include in the response for profile requests (when blank it returns all fields). Fields must be separated by commas and square brackets for nested fields (e.g. id,name,username,profile[city,region,country]).
JSON Login Enable JSON payload on login action.
JSON Register Enable JSON payload on register action.
Enable session id When enabled it overrides cookie based session with session_id parameter. This is useful when it is not possible to rely on cookie based session. This parameter can be passed as GET/POST param or as JSON field when JSON payload is enabled for the current request.
Friday, 18 April 2014 00:00

Usage

Once an end-point is published the web clients can start to make HTTP requests and consume services provided by jBackend API. It is possible to test if all is working as expected using any REST client that allows to build custom HTTP requests (much better if the client supports JSON decode to better show server responses). Some good clients are available as browser plugin for both Firefox and Chrome. We suggest REST Easy for Firefox and Postman - REST Client for Chrome.

jBackend Test End-Point

Let's assume the end-point menu item can be accessed with the following URL:

http://www.mysite.com/index.php/jbackend

Calling just the URL without any parameter we will get the following JSON response:

{
    "status": "ko",
    "error_code": "REQ_MNS",
    "error_description": "Module not specified"
}

Note that the HTTP Response Code is always 200 even in case of errors. The error condition is reported by the "status" value (ok, ko). Additional information about the error can be found in the "error_code" and the "error_description" values.

To check jBackend features it is available a sandbox with the last version of jbackend and all modules installed, and free access type on the end-point. To play with the sandbox a Postman collection is available to download here:

http://www.selfget.com/downloads/file/41-jbackapp-postman-collection.html

It needs only to be imported into Postman and is ready to play.

Push Notifications

jBackend includes a fully featured platform for sending Push Notifications over Google GCM (Android) and Apple APNs (iOS). Moreover, it supports multiple mobile applications, and you can manage them all from a single Joomla installation.

The component interface includes functions to manage Apps, Devices and Notifications, and there's a Push module to interact with jBackend from the outside (e.g. to send registration token from your app or start the push notification sending process).

Page 2 of 2