How to search/filter customers/products using python api

529 views
Skip to first unread message

rsp

unread,
Mar 30, 2012, 1:20:15 PM3/30/12
to shopi...@googlegroups.com
Several objects (such as products and customers) have a way to provide a query parameter but I'm not sure how it translates into the python api.

If I try shopify.Customer.find(q="customername"). This doesn't do anything. But I can pass some parameters this way, like "limit", "fields", etc. ??

Thanks.

Dylan Smith

unread,
Mar 30, 2012, 1:28:10 PM3/30/12
to shopi...@googlegroups.com
On Fri, Mar 30, 2012 at 1:20 PM, rsp <rpur...@gmail.com> wrote:
Several objects (such as products and customers) have a way to provide a query parameter but I'm not sure how it translates into the python api.

If I try shopify.Customer.find(q="customername"). This doesn't do anything. But I can pass some parameters this way, like "limit", "fields", etc. ??

Search queries are only available on the Customer resource as a separate search action (http://api.shopify.com/customer.html#search).

shopify.Customer.search(q="customername") should work, or to search only one the name fields you can use shopify.Customer.search(q="first_name:Dylan last_name:Smith")

rsp

unread,
Mar 30, 2012, 3:12:22 PM3/30/12
to shopi...@googlegroups.com
If I use the Customer.search method I get "Customer has no attribute 'search'". I'm using the most recent version of the ShopifyAPI I think.

Dylan Smith

unread,
Mar 30, 2012, 4:11:06 PM3/30/12
to shopi...@googlegroups.com
The feature was added in version 0.3.0, so make sure you have that installed.

~/src/shopify_python_api(master=)$ ./bin/shopify_api.py console
using shop1.localhost:3000
Python 2.7.2 (default, Sep 10 2011, 13:02:26) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.6)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(ShopifyAPI)
>>> shopify.Customer.search(q='Dylan')
[customer(2), customer(26), customer(31)]
>>> shopify.VERSION
'0.3.1'

^ It is working locally for me with the latest version.

rsp

unread,
Mar 30, 2012, 5:44:03 PM3/30/12
to shopi...@googlegroups.com
That did it, thanks!
Reply all
Reply to author
Forward
0 new messages