How to get content of the home page in Shopify Storefront API?

68 Views Asked by At

I am using the menu query to get the main-menu with Shopify GraphQL API.

It returns me menu items and all of that looks good.

{
"data": {
    "menu": {
        "id": "gid://shopify/Menu/888734372",
        "title": "Main menu",
        "itemsCount": 4,
        "items": [
            {
                "id": "gid://shopify/MenuItem/62623462",
                "title": "Home",
                "type": "FRONTPAGE",
                "url": "https:/test.myshopify.com/",
                "resourceId": null
            },
            {
                "id": "gid://shopify/MenuItem/251532",
                "title": "Electronics",
                "type": "COLLECTION",
                "url": "https://test.myshopify.com/collections/catalog",
                "resourceId": "gid://shopify/Collection/26262"
            },
            {
                "id": "gid://shopify/MenuItem/888888",
                "title": "Clothing & Accessories",
                "type": "CATALOG",
                "url": "https://test.myshopify.com/collections/all",
                "resourceId": null
            }, 
            {
                "id": "gid://shopify/MenuItem/111111",
                "title": "About",
                "type": "PAGE",
                "url": "https:/test.myshopify.com/pages/about",
                "resourceId": "gid://shopify/Page/111111"
            }
        ]
    }
}
}

It contains a menu item of type FRONTPAGE which is the client's Home page.

How I can make a query to get the response of the content for that FRONTPAGE/Home page?

When I open the front page of the store, I can see there are a few items like this:

  • Slideshow

  • Trending Products list

  • On Sale list

  • Men Fashion list

1

There are 1 best solutions below

4
David Lazar On

When you want a specific page and the data associated with it, you can use the Page endpoint of the Admin API. As in: https://shopify.dev/docs/api/admin-rest/2024-01/resources/page

That will give you at least the basics. Probably not the lists though as that stuff is going to be buried in other template aspects.