skip to Main Content

When I try this URL in my browser:

https://USERNAME:[email protected]/admin/products/tags.json

It gives me a nice list of all the tags in my shop.

I need this list, but when I try an API call with Python it says ‘Not found’. Since I can do it with my browser, there must be a way to do it programmatically.

Getting all the tags by looping over all products is too long (+- 5-10 seconds), whereas this gives me everything I need instantly.

How can I make this request?

Thanks

2

Answers


  1. The tags aren’t exposed via the REST API, but they’re accessible via the GraphQL Admin API:

    {
      shop{
        productTags(first: 100){
          edges{
            node
          }
        }
      }
    }
    

    Check this for extra info

    Login or Signup to reply.
  2. Currently, Shopify Rest API still doesn’t have an endpoint to get all tags, vendors, types. And GraphQL Admin API can only get at maximum first 250 results.

    You can get all of them through Shopify liquid ( Not working with the passworded store ).

    1. Create a new search template name: search.foo.liquid
    {% layout none %}
    {
        "vendors" : {{shop.vendors|json}},
        "types" : {{shop.types|json}},
        "tags" : {% capture output %}
            {% for collection in collections %} 
                    {% if forloop.index == 1 %}""{% endif %}
                    {% if collection.all_tags.size > 0 %}
                        {% for tag in collection.all_tags %}
                            {% if output contains tag %}
                            {% else %}
                                ,"{{tag}}"
                            {% endif %}
                        {% endfor %}  
                    {% endif %}     
            {% endfor %}
        {% endcapture %}
        {{ output | strip_newlines | prepend: '[' | append: ']' }}
    }
    
    
    1. Access: https://your-store.myshopify.com/search.json?view=foo in browser to view the result, Use cURL to get it in your application.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search