How to shopify storefront navigation menu get with API?

3.7k views Asked by At

If anyone can please help me with how to retrieve the navigation menu with REST and Graphql API.

If no API is available, then how can I write a custom Navigation API?

We need to get the below data with API. see screenshot

2

There are 2 answers

0
Roman Zenner On

currently, there is no API endpoint that would allow you to access the navigation. However, seeing that the navigation in your screenshot mainly contains collections, probably it would be a good starting point for you to read those? This can actually be done via this call:

GET /admin/api/2020-01/collection_listings.json

You can find more info here:

https://shopify.dev/docs/admin-api/rest/reference/sales-channels/collectionlisting#index-2020-01

Hope this helps, Roman

1
Rohit Mandiwal On

Use this in query. it worked for me. Remember to replace "main-menu" with the header code of your site.

{
  menu(handle:"main-menu"){
   items{
    id
    tags
    title
  }
  }
}