Undocumented API feature? Single quote in Customer search query.

We recently encountered difficulty using Shopify API to find a customer by email. We found a solution in this Shopify forum post:

https://community.shopify.com/c/Shopify-APIs-SDKs/Can-t-find-customer-by-email/m-p/702219/highlight/true#M47511

This solution seems to rely on a strange undocumented Shopify API feature. Could we get some clarity on this? Is this really a feature of Shopify API? Is it a bug? Should it be documented?

The customer in question: gid://shopify/Customer/5421928382632

This query WORKS:

{ customers(first:1, query:"email:'REDACTED") { edges { node { id email } } } }

This query DOES NOT WORK:

{ customers(first:1, query:"email:REDACTED") { edges { node { id email } } } }

This query DOES NOT WORK:

{ customers(first:1, query:"email:'REDACTED'") { edges { node { id email } } } }

So according to our tests, the only version that works is a query that has a single quote following the colon.

Note that the email in question has non-Latin characters but we are not sure if this is important.

1 Like

We did more tests, seems that there is no special :’ comparator in the Shopify API, what happened is that Shopify treated [email removed] the same as a@b.com (ignoring the malformed “email:” prefix).

For anyone that is struggling with searching for non-Latin emails (e.g. [email removed] in Shopify, here are our test results:

a@b.com               -- returns too many results
"a@b.com"             -- returns the correct result
email:a@b.com         -- returns 0 results
email:'a@b.com        -- returns too many results
email:'a@b.com'       -- returns 0 results
email:"a@b.com"       -- returns 0 results