We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Undocumented API feature? Single quote in Customer search query.

Solved

Undocumented API feature? Single quote in Customer search query.

boronine
Shopify Partner
12 2 12

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/...

 

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.

Founder and tech lead for Simple Affiliate:
https://apps.shopify.com/simple-affiliate
Accepted Solution (1)

boronine
Shopify Partner
12 2 12

This is an accepted solution.

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

For anyone that is struggling with searching for non-Latin emails (e.g. á@b.com) 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 

 

Founder and tech lead for Simple Affiliate:
https://apps.shopify.com/simple-affiliate

View solution in original post

Reply 1 (1)

boronine
Shopify Partner
12 2 12

This is an accepted solution.

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

For anyone that is struggling with searching for non-Latin emails (e.g. á@b.com) 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 

 

Founder and tech lead for Simple Affiliate:
https://apps.shopify.com/simple-affiliate