Hi please see the picture below, so that I can tell you the requirement.
Now, I have a requirement as, if I see page-1 there is content on this page which is coming from following renderings: Header, Footer, Left content 1, Left Content 2 and Right Content.
If I see page-2, there is content coming from the following renderings: Header, Footer, Left Content, Right Content 1 and Right Content 2.
For Client in page 1 the renderings "Left Content 1" and "Left Content 2" has important data which he wants through API so that he can use this data to another external website/system.
Similarly for page-2 "Right Content 1" and "Right Content 2" has important data for him.
He doesn't want the HTML for these renderings. He wants actual data used through Sitecore fields, whether single line text or rich text or any other field type. Now, what approach should I follow to provide him the data of the renderings?
In future different pages may have different renderings and their data source items may have different fields.
What I thought is: Approach One: Get page item for which client wants the data and identify the renderings (I can use a placeholder to identify which rendering is responsible for showing the data in this section of the page) which are responsible for data show. Get data source item from the rendering and get all the fields except standard fields then serialize the data and send back in response. (But this approach may get performance testing failed)
Approach Two: Identify all the possible rendering for all the pages, Get rendering's data source item and index fields(I will provide the restriction like only these fields will be indexed) for those rendering data source I will create index by rendering name so that I can get that index with rendering name (in Azure, I am using Azure for indexing). Now when the client asks me the page data, I will get that page item and check the responsible renderings and get the index with the rendering name and fetch the data for their data source items and return the serialized data.
Any other approach which is optimized will be much appreciated.
The client just knows the page name so he will provide us the page name and he should get the data for the page.