Get orders by tags?

developer8971
Tourist
44 0 2

Hi Guys,

 

I have a CSV list of order numbers (from another system) which I have tagged into the Shopify orders.  Is there a way to read all the Shopify orders by the tag?

 

Alternatively, the order number (from the other system) is also in the Notes section of the Shopify Order but includes some other text around it.  Not sure if there's a way to do a "contains" search or regex matching?

Replies 7 (7)

PageSpeedGuru
Shopify Partner
47 0 7

Hi,

 

I would do something like this:

 

GET /admin/orders.json?tags=[ comma seperated list of tag values ]

 

I think the output will be sorted by orderdate. I don't think its possible to sort by tag value.

 

You can read more here: https://help.shopify.com/en/api/reference/orders/order#index

 

 

Best regards

Good luck

Shopify PageSpeed Expert | Speed up your Shop and Earn 45% more, Get 31% more Traffic and Boost Conversion Rates by 20%
michaewa
Visitor
1 0 0

Were you able to get this to work?

 

I'm using a GET request to admin/api/2019-07/orders.json?tags=M4U

 

There is only one order with this tag, but I'm getting back dozens of results, not including the one that has this tag.

msk
Excursionist
28 5 3

hello,

Tags are commonly used for filtering and searching, yes, but not necessarily via the API. For example, the order endpoint doesn't have the ability to filter orders by tag via a GET request. However, you can filter orders in the admin by tag. 

 

Thanks

Gregarican
Shopify Partner
1033 86 286

This is doable using the GraphQL API. Although I believe the search is fuzzy based on recent posts on here. But that's a bit up in the air. Here's an example of a working test case:

 

 

 

{
  orders(first: 10, query:"tag:test_tag") {
    edges {
      cursor
      	node {
        	id
          name
          tags
      }
    }
  }
}

 

 

 

MStockSpeedling
Visitor
1 0 5

Use the word TAG instead of TAGS.

https://{store}.myshopify.com/admin/api/2021-01/orders.json?tag=readytoship

happy_shopper
Tourist
7 1 1

@MStockSpeedling thanks for that.
when testing this i ensountered the fact that it is defaulting to open orders with the tag in question.
if you want all orders of any status that match the tag then you need
https://{store}.myshopify.com/admin/api/2021-01/orders.json?tag=readytoship&status=any
just in case that is useful for anyone

 

SebasAgudelo
Shopify Partner
1 0 0

For API version 2023-07
The request must be sent through Query

GET /admin/api/2023-07/orders.json?status=any&query=tag:Pendiente

SebasAgudelo_0-1700867577192.png