Ankit Dholiya
Ankit Dholiya

Reputation: 43

How to shopify storefront navigation menu get with API?

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

Upvotes: 1

Views: 4373

Answers (2)

Rohit Mandiwal
Rohit Mandiwal

Reputation: 10462

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
  }
  }
}

Upvotes: 6

Roman Zenner
Roman Zenner

Reputation: 11

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

Upvotes: 0

Related Questions