How do I specify nested fields in the Order API?

David_Miller4
New Member
3 0 6

The API for requesting order information includes a “fields” parameter where one can specify fields of interest. Extra, unneeded data doesn’t come over the wire. Great! If one of the fields I’m interested in is line_items, is there a way to specify which fields of each line_item I want?

This request will still give me a bunch of data that I don't care about via the line_items:

https://mystore.myshopify.com/admin/orders.json?fields=id,total_price,line_items

I just need the ‘name’ field for each line item.

Thanks!

DevaGH
New Member
1 0 0

Did you find a solution for this?

0 Likes
O0O0
Shopify Staff
Shopify Staff
5 0 1

Unfortunately at this time the `fields` filtering only supports top-level fields. In other words, you can't select fields of nested objects.

0 Likes
bterrell
New Member
1 0 1

Is this something Shopify might be adding in the near future?  

Matt_Bertino
New Member
5 0 0

Is any update on this at this time? I've got a similar scenario and the entire line_items object to just a ton of data that isn't necessary.

0 Likes
RC_CH
New Member
1 0 1

Hi ,

I am also looking for the solution for this. Not sure if Shopify has added this feature which I feel really a good feature. 

Hope they will add it soon if not already done. Please confirm how can we access the nested field if already done.

Thnks & regards,

RC

Greg_Kujawa
Shopify Partner
1016 83 229

I've found when working with most API providers...it's better to get too much data than too little. :) Sometimes there can be a lack of API endpoint properties, or a litany of nested relational fields that have to be queried.

So in those cases you either can't retrieve the data, or else have to make several iterative calls to retrieve the data you are looking for. While I get it, in that you have to parse through the response sets and ignore a lot of fields that you don't need or care about. But it's far better than the alternative. And at least we can issue REST API queries with filter criteria. Some API providers lack enough of this functionality. So besides unnecessary fields in the responses, you have to discard entire records that aren't what you're looking for! 

0 Likes
Matt_Bertino
New Member
5 0 0

I typically agree with everything you are saying. 

I won't speak for anyone else but the main reason I'd like to see this is due to memory consumption issues at scale. 

While working on hosted application platforms like heroku you are often memory constrained. And while it's nice to have all the data for testing purposes it's create a memory problem when you are trying to import 250 orders at a time and the line_items array of objects is massive. 

It's caused us to lower this to retrieving 100 orders at a time which of course means more API call in general but other than beefing up our own dynos (cost prohibitive for some) there's really not an option. 

0 Likes
Varun_Dhondea
New Member
1 0 0

Hi,

Has this feature been implemented?


Thanks

0 Likes