Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Which APIs to use?

Avatar

Level 7

Hi,

We have various APIs to use in AEM coding: jcr api, Jackrabbit API, wcm api and sling api.

How do we choose from these APIs?

I would think I should use Sling API, as it is a high level one and probably this is Adobe's expectation also.

Appreciate your responses.

Thanks,

Rama.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

In general, these APIs just work on different levels of abstraction, and using a high-level APIs is often recommended, as sometimes the layout on the repository level is well-known, but technically an implementation detail and could change with every release. So, start with the API on a WCM level, and all resource-handling should be done using the Sling Resource API.

The only reason to use the JCR API is only the use of nodetypes, which is often required, but not supported by Sling.

kind regards,
Jörg

View solution in original post

7 Replies

Avatar

Level 10

Hi,

Your question seems to be too generic.

  • Usage of a API depends upon what you are actually trying to achieve / objective, then
  • Which APIs can help you to get that done, then
  • Choose the simple one to implement and efficient.

Thanks

Avatar

Level 7

I mean to ask:

1. Why so many APIs are created?

2. Given that all these APIs serve our purpose, which one to use?

Something like, use high level APIs (Sling APIs) in general, but if more fine grained function calls are required, use JCR API.

Something like JCR API has performance benefits.....

Adobe recommends ......

Thanks,

Rama.

Avatar

Level 10

Reason being Apache Sling is not a Adobe product

again Adobe CRX is based on Apache JCR 

All these are designed and developed individually for various purpose but when you combine these you get different ways to do a particular task

Avatar

Level 10

As Praveen stated - the API you use all depends upon what you want to do. AEM is a large product with many pieces of functionality.  Hence is the reason why there are many APIs for that reason.

For example - if you wan to programmatically work with DAM Assets - you use the AssetManager API. If you want to create a custom workflow - you use the AEM Workflow APIs. If you want to query the JCR - you can use QUeryBuilder API or JCR API. If you want to work with databases, you can use the DataSourcePool API. 

We have a lot of community articles that get you up and running with the various AEM APIs. You can see them here: 

https://helpx.adobe.com/marketing-cloud/experience-manager.html

Hope this helps. 

Avatar

Level 7

Hi,

I understand this part.

My only question is if the same specific function could be achieved by JCR API, Sling API, WCM API and Jackrabbit API, which API should the developer choose?

Are there any parameters to consider?

Thanks,

Rama.

Avatar

Correct answer by
Employee Advisor

Hi,

In general, these APIs just work on different levels of abstraction, and using a high-level APIs is often recommended, as sometimes the layout on the repository level is well-known, but technically an implementation detail and could change with every release. So, start with the API on a WCM level, and all resource-handling should be done using the Sling Resource API.

The only reason to use the JCR API is only the use of nodetypes, which is often required, but not supported by Sling.

kind regards,
Jörg

Avatar

Level 7

Perfect. This is the kind of answer I have been waiting for.

Now my knowledge on this topic got enhanced.

Many thanks to all who replied.

Rama.