Menu Items / Navigation by API

Thomas_Mayer
New Member
1 0 6

Hi Experts!

I studied the Shopify API but didn't found an endpoint to gain information about Menu Items (or Navigation item). I found custom_collections.json and collects.json which will helps to understand the core structure of a shop. But is there also a way to get the menu structure of a shop as well?

Thanks a lot for you valuable answer;)

Best,

Thomas

Replies 14 (14)
Jason
Shopify Expert
10882 190 2179

Hey Thomas,

There's currently no API for linklists (menus) so the ability to add / remove or edit those needs to be done within the Admin directly.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
Pogodan
Shopify Expert
76 0 13

+1 for managing menu items via the API

Pogodan | https://experts.shopify.com/pogodan-dev
Carlos_Cabada
Shopify Partner
3 0 3

+1 for managing menu items via the API

Phil_Gunhouse
Shopify Partner
4 0 4

The post may be flagged 'outdated' but the requirement is still current with no indication of what, if any, priority it has...

+1 for managing menu items via the API

Specifically for synching multiple language/currency sites.

Maris
Shopify Partner
313 5 68

Yes, totally agree - this is a major pain point that there is no API access to Navigation.

@Shopify, any comments on plans around that?

 

Matrixify (Excelify) | Bulk Import Export Update Migrate | https://matrixify.app
martinR1
Shopify Partner
19 1 7

Linklists (menus) done manually directly within the Admin is OK except when the number of menus is large or when they are dynamic in nature ( changing often ).

Access through an API class to add/remove/edit would be extremily useful.

Any indication of when they will be done ?

Horas
Excursionist
10 0 5

+1 for managing menu items via the API

Jordan_Cooperm1
Excursionist
14 0 4

What about fetching navigation? In my case, I don't mind managing via dashboard, but I want to fetch the nav as JSON to load it with React instead of liquid.

Stephen_Gardner
Shopify Partner
29 0 10

This is a huge feature missing from a phenomenal API.  Certainly looking forward to when this is available!  

Semih_Gökyer
Shopify Partner
5 0 4

+1 for managing menu items via the API

David_Bilsky
Shopify Expert
2 0 13

Aye, for several of our clients I have multiple large menus that have to be kept in sync between multiple stores (eg: dev store and live store; country-specific stores; etc.)  Huge +1 for being able to read and write navigation items via API, would save a lot of time on tedious data entry/maintenance

Basepaws-Tech
New Member
1 0 0

+1 for API menu links  reading/edeting

mykase
New Member
2 0 0

Of course this api is missing

+10000000000 for API menu links  reading/editing

Grady_Woodruff
New Member
1 0 2
If you make a file called `index.navigation.liquid` you can access it at `http://site.com/?view=navigation`
Put the following code in the the file and it will return a json object with your navigation
 
------------------------
templates/index.navigation.liquid
------------------------
{%- liquid
layout none

 

assign links = ''
assign delimiter_1 = '%'
assign delimiter_2 = ','
assign delimiter_3 = '&'
assign delimiter_4 = '|'

 

for link in linklists.collection-layout.links
    assign children = ''
    for child_link in link.links
        if children == ''
            assign separator = ''
        else
            assign separator = delimiter_2
        endif
        assign children = children | append: separator | append: child_link.title | append: delimiter_3 | append: child_link.handle | append: delimiter_3 | append: child_link.url
    endfor

 

    if links == ''
        assign separator = ''
    else
        assign separator = delimiter_1
    endif
    assign links = links | append: separator | append: link.title | append: delimiter_4 | append: link.handle | append: delimiter_4 | append: link.url | append: delimiter_4 | append: children
endfor

 

assign links = links | split: delimiter_1
-%}

 

[
    {%- for link in links -%}
        {%- assign link_data = link | split: delimiter_4 -%}
        {
            "title": {{ link_data[0] | json }},
            "handle": {{ link_data[1] | json }},
            "url": {{ link_data[2] | json }},
            "children": [
                {%- assign child_links = link_data[3] | split: delimiter_2 -%}
                {%- for child_link in child_links -%}
                    {%- assign child_link_data = child_link | split: delimiter_3 -%}
                    {
                           "title": {{ child_link_data[0] | json }},
                           "handle": {{ child_link_data[1] | json }},
                           "url": {{ child_link_data[2] | json }}
                    }{%- unless forloop.last -%},{%- endunless -%}
                {%- endfor -%}
            ]
        }{%- unless forloop.last -%},{%- endunless -%}
    {%- endfor -%}
]