Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Best practice for creating APIs in AEM

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

22-03-2021

In Java projects, one would usually use spring boot, and generate versioned apis from annotated controllers and models and use swagger to test/document.  APIs would include customer login, registration, edit details, get order history etc.  Some calls search and return content, e.g using sql2 and some will hit back ends behind aem.  They would use Json. 

 

while we could hand write servlets which manually unmarshal and marshal request and response objects, this would be like going back to the 80s.

 

Does aem have a recommended way to create versioned apis for the front end to consume, with built in documentation generation?

 

I saw there is a swagger aem project, but not sure how this would work with aem not being spring or mvc

 

i understand that aem uses sling, but I haven’t found a tutorial on how this might be used, and the sling servlet reference docs don’t seem to have a way to specify the actual type of the request and response other than as SlingHttpServletRequest and SlingHttpServletResponse, which require writing your own get param extraction and writing your own json out (vs something which takes a java object and constructs the json for you). I haven’t seen something like swagger for it?  

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
Level 7
KiranVedantam1992
Level 7

Likes

169 likes

Total Posts

180 posts

Correct Reply

54 solutions
Top badges earned
Springboard
Give Back 5
Ignite 1
Affirm 50
Validate 1
View profile

Avatar
Springboard
Level 7
KiranVedantam1992
Level 7

Likes

169 likes

Total Posts

180 posts

Correct Reply

54 solutions
Top badges earned
Springboard
Give Back 5
Ignite 1
Affirm 50
Validate 1
View profile
KiranVedantam1992
Level 7

23-03-2021

Answers (1)

Answers (1)

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,112 likes

Total Posts

3,145 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,112 likes

Total Posts

3,145 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

25-03-2021

Unlike other frameworks, AEM is resource-based, and the resource defines the contract in the first place, but not the code. The most API-like thing, which comes close to the idea of other frameworks are Content-Fragments because there the structure and the content is clear. Also the SlingModel Exporter gives you the chance to control the details of the payload you get. So when you use AEM as a remote system (in a kind of headless way), these are the APIs you should look for.

 

Jörg