Querying Shipments w/ SKU

What is the best way to turn a JSON response into a flat data table? I have a shipments query that requires SKU and order_number. This is my query (formatted in R):

query ← paste0(
“{\n”,
" shipments(\n",
" date_from: "“, date_from_converted, “"\n”,
" date_to: "”, date_to_converted, “"\n”,
" ) {\n",
" request_id\n",
" complexity\n",
" data {\n",
" edges {\n",
" node {\n",
" id\n",
" legacy_id\n",
" order_id\n",
" user_id\n",
" warehouse_id\n",
" pending_shipment_id\n",
" address {\n",
" name\n",
" address1\n",
" address2\n",
" city\n",
" state\n",
" country\n",
" zip\n",
" phone\n",
" }\n",
" shipped_off_shiphero\n",
" dropshipment\n",
" created_date\n",
" line_items(first: “, line_items_converted,”) {\n",
" edges {\n",
" node {\n",
" line_item_id\n",
" quantity\n",
" }\n",
" }\n",
" }\n",
" shipping_labels {\n",
" id\n",
" legacy_id\n",
" account_id\n",
" tracking_number\n",
" carrier\n",
" shipping_name\n",
" shipping_method\n",
" cost\n",
" profile\n",
" packing_slip\n",
" warehouse\n",
" insurance_amount\n",
" carrier_account_id\n",
" source\n",
" status\n",
" created_date\n",
" }\n",
" order {\n",
" order_number\n",
" shop_name\n",
" line_items(first: “, line_items_converted,”) {\n",
" edges {\n",
" node {\n",
" sku\n",
" }\n",
" }\n",
" }\n",
" }\n",
" }\n",
" }\n",
" }\n",
" }\n",
“}\n”
)

I’ve come up with a workaround to get order_number which is nested under order. However, grabbing SKU which is further nested under order > line_items may be out of my technical depth. Any suggestions for simplifying? Am I missing something? Is the only way to iterate through each sublist?

Hi @chilicrunch! Welcome to our Community.

As for your inquiry about turning a JSON into a flat table, I cannot speak as we don’t provide support for coding, only for using our API.

For a quick explanation of edges and pagination, you can check out the documentation here: GraphQL Primer – Developer Resources | ShipHero.

If you require order_number and SKUs, is there any particular reason you are using shipments query vs orders query? I’m trying to understand what is the exact outcome you are trying to reach.

have a great day!