Daniel Dickison
unread,May 16, 2010, 10:58:36 AM5/16/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to etsy-...@googlegroups.com
I'm trying to figure out the best way to get nested associations from a query without having to make multiple API calls. My specific use case is to fetch all of a user's favorite listings, along with thumbnail images and seller names. So, using a hypothetical shell-expansion-like syntax, I need something like:
/users/:user_id/favorites/listings?includes=Listing/{Images,Shop}
Ideally I want to do this query when fetching a user's other info, and with field filtering, so I want:
/users/:user_id?includes=FavoriteListings/Listing/{Images(url_50x50),Shop(login_name)}
After some trial and error, I found that I can include the same association multiple times in an includes parameter, so I can achieve this by doing:
/users/:user_id?FavoriteListings/Listing/Images(url_50x50),FavoriteListings/Listing(listing_id)/User(login_name)
This returns redundant data (each FavoriteListing shows up twice, once for the Images "subquery" and once for the User "subquery"). It's possible to minimize the duplicity by filtering unneeded fields from the second subquery, but it still seems a bit hacky.
Can I count on this method to keep working? Or is there (or will there be) a better way to do this type of thing?
Daniel