{"id":2546,"date":"2024-12-31T20:22:45","date_gmt":"2024-12-31T20:22:45","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/magento-2-api-get-cms-page-content\/"},"modified":"2025-04-24T09:37:41","modified_gmt":"2025-04-24T04:07:41","slug":"magento-2-api-get-cms-page-content","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/magento-2-api-get-cms-page-content\/","title":{"rendered":"Magento 2 API &#8211; Get CMS Page Content"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello Magento Peeps!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Welcome to Meetanshi\u2019s Magento 2 API \u2013 Get CMS Page Content tutorial. This post is part of our Magento 2 API series. In case you are a budding developer, do check out our other&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-api\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 API tutorials<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, let\u2019s begin with&nbsp;<em><strong>Magento 2 API \u2013 Get CMS Page Content<\/strong><\/em>!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/ecommerce-mobile-app-development-cost\/\">developing a mobile shopping app<\/a>&nbsp;on Magento 2, you may require to fetch the CMS pages and block to show it to the customers. Not to forget that Magento 2 is a robust eCommerce platform that provides plenty of powerful APIs to harness the full potential of the platform. In this blog post, I will be showing you how to get CMS page content using Magento 2 APIs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Get CMS Page &amp; Block Content Using Magento 2 API?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In order to get the CMS page and block content in Magento 2 through APIs, we need to perform a GET call to the respective path with the path KEY and variable ID. Let\u2019s understand it in a more better way using examples.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get CMS Page in Magento 2<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ll be sending a GET request to&nbsp;<em>store_url\/cmsPage\/:aboutCmsid&nbsp;<\/em>with the required page id to get CMS page in Magento 2. Refer to the example provided below for more details.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Method:&nbsp;<\/strong>GET<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>URL:&nbsp;<\/strong><em>store_url\/cmsPage\/:aboutCmsid<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Path Variables<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>VALUE:&nbsp;<\/strong>aboutCmsid<\/li>\n\n\n\n<li><strong>KEY:&nbsp;<\/strong>5<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/05\/Get-About-CMS-Page-700x418-1.png\" alt=\"Get About CMS Page\" class=\"wp-image-50343\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Response:&nbsp;<\/strong>The response returns the required page.<br><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n \n    \"id\": 5,\n \n    \"identifier\": \"about-us\",\n \n    \"title\": \"About us\",\n \n    \"page_layout\": \"1column\",\n \n    \"meta_keywords\": \"\",\n \n    \"meta_description\": \"\",\n \n    \"content_heading\": \"About us\",\n \n    \"content\": \"&lt;div class=\"about-info cms-content\">n      &lt;p class=\"cms-content-important\">With more than 230 stores spanning 43 states and growing, Luma is a nationally recognized active wear manufacturer and retailer. We\u2019re passionate about active lifestyles \u2013 and it goes way beyond apparel.&lt;\/p>nn      &lt;p>At Luma, wellness is a way of life. We don\u2019t believe age, gender or past actions define you, only your ambition and desire for wholeness... today.&lt;\/p>nn      &lt;p>We differentiate ourselves through a combination of unique designs and styles merged with unequaled standards of quality and authenticity. Our founders have deep roots in yoga and health communities and our selections serve amateur practitioners and professional athletes alike.&lt;\/p>nn      &lt;ul style=\"list-style: none; margin-top: 20px; padding: 0;\">n          &lt;li>&lt;a href=\"{{store url=\"contact\"}}\">Contact Luma&lt;\/a>&lt;\/li>n          &lt;li>&lt;a href=\"{{store url=\"customer-service\"}}\">Customer Service&lt;\/a>&lt;\/li>n          &lt;li>&lt;a href=\"{{store url=\"privacy-policy\"}}\">Luma Privacy Policy&lt;\/a>&lt;\/li>n          &lt;li>&lt;a href=\"{{store url=\"\"}}\">Shop Luma&lt;\/a>&lt;\/li>n      &lt;\/ul>n  &lt;\/div>n\",\n \n    \"creation_time\": \"2020-11-30 12:49:33\",\n \n    \"update_time\": \"2020-11-30 12:49:33\",\n \n    \"sort_order\": \"0\",\n \n    \"layout_update_xml\": \"\",\n \n    \"custom_theme\": \"\",\n \n    \"custom_root_template\": \"\",\n \n    \"active\": true\n \n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it! This is how you can get the cms page in Magento 2 through API.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Get CMS Block in Magento 2<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In order to get the CMS block in Magento 2 through API, the client needs to send a GET request to the&nbsp;<em>store_url\/cmsBlock\/&nbsp;<\/em>and pass the variables in the parameters. Refer to the following example for more understanding.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Method:&nbsp;<\/strong>GET<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>URL:&nbsp;<\/strong><em>store_url\/cmsBlock\/:homeCmsid<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Path Variables<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>KEY:&nbsp;<\/strong>homeCmsid<\/li>\n\n\n\n<li><strong>VALUE:&nbsp;<\/strong>9<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/05\/Get-Block-CMS-700x410-1.png\" alt=\"Get Block CMS\" class=\"wp-image-50346\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Response:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The request will return the required page details in the following format:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n \n    \"id\": 9,\n \n    \"identifier\": \"training-block\",\n \n    \"title\": \"Training Block\",\n \n    \"content\": \"&lt;div class=\"blocks-promo\">nn    &lt;a href=\"{{store url=\"\"}}training.html\" class=\"block-promo training-main\">n        &lt;img src=\"{{media url=\"wysiwyg\/training\/training-main.jpg\"}}\" alt=\"\" \/>n        &lt;span class=\"content\">n            &lt;strong class=\"title\">n                &lt;span>Motivate&lt;\/span> yourself.&lt;br \/>n                &lt;span>Reach&lt;\/span> goals.&lt;br \/>n                &lt;span>Boost&lt;\/span> ambition.&lt;br \/>n                &lt;span>Max&lt;\/span> fitness.&lt;br \/>n                &lt;span>Upgrade&lt;\/span> lifestyle.n            &lt;\/strong>n        &lt;\/span>n    &lt;\/a>n    &lt;a href=\"{{store url=\"\"}}collections\/erin-recommends.html\" class=\"block-promo training-erin\">n        &lt;img src=\"{{media url=\"wysiwyg\/training\/training-erin.jpg\"}}\" alt=\"\" \/>n        &lt;span class=\"content\">n            &lt;strong class=\"title\">Before creating Luma, pro trainer Erin Renny helped world-class athletes reach peak fitness&lt;\/strong>n            &lt;span class=\"info\">Hand-selected by Erin, our training downloads reflect a commitment to yoga, health and wellness.&lt;\/span>n        &lt;\/span>n    &lt;\/a>n    &lt;a href=\"{{store url=\"\"}}training\/training-video.html\" class=\"block-promo training-on-demand\">n        &lt;span class=\"content\">n            &lt;span class=\"icon download\">&lt;span>Download&lt;\/span>&lt;\/span>n            &lt;strong class=\"title\">Training on demand&lt;\/strong>n            &lt;span class=\"info\">Luma downloads to inspire and&amp;nbsp;challenge.&lt;br \/>Your space, your pace&lt;\/span>n            &lt;span class=\"more icon\">Videos&lt;\/span>n        &lt;\/span>n    &lt;\/a>n&lt;\/div>n&lt;div class=\"content-heading\">n    &lt;h2 class=\"title\">Top Videos&lt;\/h2>n    &lt;p class=\"info\">Stream free with subscription&lt;\/p>n&lt;\/div>n{{widget type=\"Magento\\CatalogWidget\\Block\\Product\\ProductsList\" products_count=\"4\" template=\"product\/widget\/content\/grid.phtml\" conditions_encoded=\"^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`,`aggregator`:`all`,`value`:`1`,`new_child`:``^],`1--1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Product`,`attribute`:`sku`,`operator`:`()`,`value`:`241-MB08, 240-LV05, 240-LV09, 240-LV07`^]^]\"}}\",\n \n    \"creation_time\": \"2020-11-30 12:49:33\",\n \n    \"update_time\": \"2020-11-30 12:49:33\",\n \n    \"active\": true\n \n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it! <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is how you can get the cms page in Magento 2 through API.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 API is useful while developing another applications based on the platform. Magento 2 API CMS page &amp; block content is useful to show the contents of the website on other applications. I hope this blog post will help you through the same. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In case you still have any queries or doubts regarding the solution provided, feel free to comment. I would be happy to help you. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for reading. <\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button btn-orange\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/meetanshi.com\/blog\/magento-2-api-get-all-store-ids-names-codes\/\">Magento 2 API \u2013 Get All Store<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button btn-orange\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/meetanshi.com\/blog\/magento-2-api-get-cms-page-content\/\">Magento 2 API \u2013 Get CMS Content<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello Magento Peeps! Welcome to Meetanshi\u2019s Magento 2 API \u2013 Get CMS Page Content tutorial. This post is part of our Magento 2 API series&#8230;.<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2546","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2546"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2546\/revisions"}],"predecessor-version":[{"id":12880,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2546\/revisions\/12880"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}